1. Go to this page and download the library: Download dc/ioc library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dc / ioc example snippets
$container = new \DC\IoC\Container();
$container
->register('\Car') // fully qualified namespace
->to('\IVehicle')
->withContainerLifetime(); // lives as long as the container
$container
->register(function(){
new \Car();
})->to('\IVehicle');
$vehicle = $container->resolve('\IVehicle');
$vehicles = $container->resolveAll('\IVehicle');
classTrailer{
public __construct(\IVehicle $vehicle) {
// attach your Trailer to you IVehicle, or something
}
}
$container->resolve("Trailer"); // you don't even have to register Trailer