PHP code example of lapaz / aura-di-ext

1. Go to this page and download the library: Download lapaz/aura-di-ext 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/ */

    

lapaz / aura-di-ext example snippets


$di->set('routerContainer', $di->lazy(function () use ($di) {
    $routerContainer = $di->newInstance(\Aura\Router\RouterContainer::class, [], [
        'setLoggerFactory' => function () use ($di) {
            return $di->get('logger');
        },
        // Don't use ->lazyGet() because the returned lazy object would be evaluated before injection.
    ]);

    $map = $routerContainer->getMap();
    $map->get('index', '/');
    // ...

    return $routerContainer;
));

$dix = ContainerExtension::createFrom($di);

$di->set('routerContainer', $dix->lazyNew(\Aura\Router\RouterContainer::class, [], [
    'setLoggerFactory' => $dix->newLocator('logger'),
])->modifiedBy(function ($routerContainer) {
    $map = $routerContainer->getMap();
    $map->get('index', '/');
    // ...
));

$dix = ContainerExtension::createFrom($di);

$di->params[\Aura\Dispatcher\Dispatcher::class]['objects'] = $dix->lazyRequire(__DIR__ . '/objects.php', [
    'di' => $di,
    // 'anotherConfig' => ...
]);