switon / di
Dependency injection container and autowiring for Switon Framework
v1.0.0
2026-05-09 15:07 UTC
Requires
- php: >=8.3
- ext-json: *
- psr/container: ^2.0
- psr/event-dispatcher: ^1.0
- switon/core: ^1.0
Requires (Dev)
- phpunit/phpunit: ^12.0
README
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.