HexMakina / LeMarchand

Basic PSR11 container build for kadro
MIT License
1 stars 0 forks source link
php php7 psr-11 psr-12

Scrutinizer Code Quality

PSR-4 Compliant PSR-11 Compliant PSR-12 Compliant PHP 7.0 Required

Latest Stable Version License

LeMarchand

Basic PSR-11 container build for kadro framework, for now being a Service Locator flirting with notions of Dependency Injection

Install

composer require hexmakina/le-marchand

Usage

Instantiante and load configuration array

$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

Register additionnal services

$box=new LeMarchand($settings);
$box->register('HexMakina\Crudites\DatabaseInterface', $database);

Do we have a configuration ?

Can we get it ?

By PSR-11 law:

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

Lore & Hommage

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".