lebran / container
The simple di for lebran projects.
dev-master
2016-02-16 14:43 UTC
Requires
- php: >=5.5
- container-interop/container-interop: >=1.1.0
Requires (Dev)
- phpunit/phpunit: 4.8.9
This package is not auto-updated.
Last update: 2024-11-05 05:00:53 UTC
README
Simple dependency injection container
Installation
Require in your project with composer :
$ composer require lebran/container
Example
In your bootstrap file index.php
:
<?php // Include autoloader include __DIR__."/vendor/autoload.php"; // Create service container $di = new \Lebran\Container(); // Container supports 3 types of definition // Type 1: Object $di->set('myservice', new \MyNamespace\MyService()); // Type 2: String $di->set('myservice2', '\MyNamespace\MyService2'); // Type 3: Closure $di->set('myservice3', function(){ return new \MyNamespace\MyService3(); } ); // Getting service $di->get('myservice');
Extended example coming soon ...