1. Go to this page and download the library: Download fabs/di 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/ */
fabs / di example snippets
$di = DI::getDefault();
$di->set('function_example',function(){
return new MyCustomService();
});
// or
$di->set('class_name_example', MyCustomService::class);
// or
$di->set('parameter_example',function($first,$second){
return new MyCustomService($first, $second);
})->setParameters([1,'second']);
$di = DI::getDefault();
$di->set('test_service', new MyCustomService());
$di = DI::getDefault();
$di->setShared('test_service', new MyCustomService());
// or
$di->set('test_service', new MyCustomService(), true);
$di = DI::getDefault();
$service = $di->get('test_service');
// or
$service = $di['test_service'];
// or
$service = $di->get('parameter_example',[8,'example']);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.