1. Go to this page and download the library: Download vertilia/container 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/ */
vertilia / container example snippets
// services.php
namespace Vertilia\Container;
return [
// instantiating via callback
EnvMockInterface::class => function () {
return new EnvMock();
},
// instantiating via array of service names
ServiceMock::class => [EnvMockInterface::class],
// instantiating via callback with additional params allowed
'ServiceMockAlias' => function (...$args) {
return new ServiceMock($this->get(EnvMockInterface::class), ...$args);
},
// returning existing object
'ServiceMockObject' => (object) 'test string',
// returning string value
'ServiceMockString' => 'test string',
// returning other scalar value
'ServiceMockInt' => 42,
];
// bootstrap.php
$app = new \Vertilia\Container\ServiceContainer([__DIR__ . '/services.php']);