PHP code example of kris-ro / php-dependency-injection
1. Go to this page and download the library: Download kris-ro/php-dependency-injection 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/ */
kris-ro / php-dependency-injection example snippets
use KrisRo\PhpDependencyInjection\Container;
# first build the configuration array. See more at https://github.com/kris-ro/php-config
Container::buildConfig('/absolute/path/to/your/folder/with/json/files');
# load the service you need
$pdo = Container::service('myPDO');
$model = Container::service('model');
$validator = Container::service('validator');