PHP code example of phpnomad / php-di-integration

1. Go to this page and download the library: Download phpnomad/php-di-integration 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/ */

    

phpnomad / php-di-integration example snippets


use PHPNomad\Integrations\PhpDi\Container\CompiledContainerLoader;
use PHPNomad\Integrations\PhpDi\Initializer as PhpDiInitializer;
use PHPNomad\Loader\Bootstrapper;

$container = CompiledContainerLoader::load($tier); // tier identifies the compiled artifact
(new Bootstrapper(
    $container,
    new PhpDiInitializer(),    // Container + Config + Registry sub-initializers
    new YourCoreInitializer(),
    // ...
))->load();

use PHPNomad\Integrations\PhpDi\Container\Initializer as ContainerInitializer;
use PHPNomad\Integrations\PhpDi\Config\Initializer as ConfigInitializer;

(new Bootstrapper(
    $container,
    new ContainerInitializer(),
    new ConfigInitializer(),
    // skip Registry — keep PHPNomad's simple registry impl
    new YourCoreInitializer(),
))->load();

use PHPNomad\Integrations\PhpDi\Container\Compiler;

$initializers = [
    new \PHPNomad\Integrations\PhpDi\Initializer(),
    new YourCoreInitializer(),
    // ...recurse into Loaders to flatten sub-initializers...
];

Compiler::compileForTier(
    tier:      'lite',
    outDir:    __DIR__ . '/build/lib/Compiled/PhpDiContainer',
    initializers: $initializers,
);
bash
composer