Skip to content

switon-php/di

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Switon DI Package

Dependency injection container and autowiring for Switon Framework.

Installation

composer require switon/di

Requirements: PHP 8.3+, ext-json

Quick Start

use Switon\Core\Attribute\Autowired;
use Switon\Di\Container;
use Switon\Di\ServiceProvider;

interface CacheInterface {}
class Cache implements CacheInterface {}

class ProductService
{
    #[Autowired] protected CacheInterface $cache;
}

$container = new Container();
(new ServiceProvider())->register($container);
$productService = $container->get(ProductService::class);

Docs: https://docs.switon.dev/latest/di

License

MIT.

About

Property-based dependency injection with interface autowiring, named slots, and shared versus fresh instances for Switon Framework

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages