PHP code example of php-di / kernel

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

    

php-di / kernel example snippets


$kernel = new Kernel([
    'twig/twig',
    'doctrine/dbal',
    'vendor/app',
]);

$container = $kernel->createContainer();

    $kernel = new Kernel();
    $kernel->addConfig([
        'db.host' => 'localhost',
    ]);
    

    $kernel = new Kernel([
        'twig/twig',
    ]);
    

$kernel = new Kernel([
    'foo/bar',
]);

$kernel = new Kernel([
    'app',
]);

$kernel = new Kernel($modules, 'dev'); // dev environment
$kernel = new Kernel($modules, 'prod'); // prod environment

composer 

res/
    config/
        config.php
        env/
            dev.php
            prod.php
    ...