Dependency injection container and autowiring for Switon Framework

Maintainers

Package info

github.com/switon-php/di

Documentation

pkg:composer/switon/di

Statistics

Installs: 92

Dependents: 10

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-05-09 15:07 UTC

This package is auto-updated.

Last update: 2026-05-09 15:13:41 UTC


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.