carousel / container
Dependency Injection container for PHP projects
v1.0.0
2017-02-23 09:07 UTC
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/phpunit: 5.2.*
- scrutinizer/ocular: ~1.1
- squizlabs/php_codesniffer: ~2.3
This package is not auto-updated.
Last update: 2024-12-21 19:43:06 UTC
README
#Simple dependency injection container for PHP projects
Installation
With Composer
$ composer require carousel/container
composer.json
{
"require": {
"carousel/container": "0.4.0"
}
}
Usage
//bind object into the container (using ArrayAccess) $this->container['car'] = function () { return new Car(); }; //resolve $car = $this->container['car']; //call object method $car->setMake('VW'); //swap binding key $this->container->swapKey('car', 'new_car'); //resolve $new_car = $this->container['new_car'];