1. Go to this page and download the library: Download gr8abbasi/php-di-container 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/ */
gr8abbasi / php-di-container example snippets
use Mcustiel\Config\Drivers\Reader\php\Reader as PhpReader;
use Mcustiel\Config\Drivers\Reader\ini\Reader as IniReader;
use Mcustiel\Config\Drivers\Reader\json\Reader as JsonReader;
use Mcustiel\Config\Drivers\Reader\yaml\Reader as YamlReader;
$loader = new ServiceLoader();
$services = $loader->loadServices(
__DIR__ . "/Fixtures/phpServicesConfig.php",
new PhpReader()
);
$container = new Container($services);
// To get services from container
$service = $container->get('foo');
$services = $loader->loadServices(
__DIR__ . "/Fixtures/jsonServicesConfig.json",
new JsonReader()
);
$services = $loader->loadServices(
__DIR__ . "/Fixtures/yamlServicesConfig.yml",
new YamlReader()
);
$services = $loader->loadServices(
__DIR__ . "/Fixtures/iniServicesConfig.ini",
new IniReader()
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.