PHP code example of shadowhand / cairon

1. Go to this page and download the library: Download shadowhand/cairon 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/ */

    

shadowhand / cairon example snippets


use Auryn\Injector;
use Cairon\InjectorConfig;

$injector = InjectorConfig::make()
    ->configure([
        Acme\Injector\Foo::class,
        ['SomeClass::staticMethod']
        function (Injector $injector) { /* ... */ }
        // ...
    ])
    ->apply([$someObject, 'method'])
    ->injector();

use Auryn\Injector;
use Psr\Http\Message\ServerRequestInterface;
use Zend\Diactoros\ServerRequest;
use Zend\Diactoros\ServerRequestFactory;

return function (Injector $injector) {
    $injector->alias(ServerRequestInterface::class, ServerRequest::class);
    $injector->delegate(ServerRequestInterface::class, 'ServerRequestFactory::fromGlobals');
};

use Cairon\InjectorConfig;

$injector = InjectorConfig::make()
    ->configure([
        

$injector = new Injector();

$config = InjectorConfig::make($injector);

assert($injector === $config->injector());