PHP code example of bnf / di
1. Go to this page and download the library: Download bnf/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/ */
bnf / di example snippets
Bnf\Di\Container;
use Psr\Container\ContainerInterface;
use Interop\Container\ServiceProviderInterface;
$container = new Container([new class implements ServiceProviderInterface {
public function getFactories(): array
{
return [
stdClass::class => function (ContainerInterface $container): stdClass {
return new stdClass;
}
];
}
public function getExtensions(): array
{
return [];
}
}]);
$class = $container->get(stdClass::class);
var_dump($class);