Basic PSR-11 container build for kadro framework, for now being a Service Locator flirting with notions of Dependency Injection
composer require hexmakina/le-marchand
$settings = [
'app' => [
'name' => 'KORAL',
'production_host' => 'engine.hexmakina.be',
'session_start_options' => ['session_name' => 'koral-alias'],
'time_window_start' => '-3 months',
'time_window_stop' => '+1 month',
],
'controller_namespaces' => [
'App\\Controllers\\',
'HexMakina\\koral\\Controllers\\',
'HexMakina\\kadro\\Controllers\\'
]
];
$box=new LeMarchand($settings);
Settings will be retrievable with the 'settings' key, meaning:
$box->has('settings'); // returns true;
$box->has('settings.app.name'); // return true;
$box->get('settings.app.name'); // returns KORAL
$box=new LeMarchand($settings);
$box->register('HexMakina\Crudites\DatabaseInterface', $database);
By PSR-11 law:
$box->has('NonExistingKey'); //return false
$box->get('NonExistingKey'); //throws a Psr\Container\NotFoundExceptionInterface
get takes one mandatory parameter: an entry identifier, which MUST be a string
$box->has(23); // return false;
$box->get(23); // throws a Psr\Container\ContainerExceptionInterface
The LeMarchand box that has become known in the Hellraiser film series as the Lament Configuration was introduced in The Hellbound Heart novella as "the Lemarchand Configuration".