PHP code example of rwillians / simple-di
1. Go to this page and download the library: Download rwillians/simple-di library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rwillians / simple-di example snippets
use Rwillians\SimpleDI\Container;
use Rwillians\SimpleDI\Contracts\ServiceLocatorInterface;
$container = new Container([
'foo' => 'bar',
'bar' => 'baz',
'baz' => 10,
]);
$container->set('awsome.number', function (ServiceLocatorInterface $serviceLocator) {
return $serviceLocator->get('baz') + 5;
});
echo $container->resolve('awsome.number'); // Outputs 15 (10 + 5)