1. Go to this page and download the library: Download tr33m4n/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/ */
use tr33m4n\Di\Config;
use tr33m4n\Di\Container;
use tr33m4n\Di\Container\GetParameters;
use tr33m4n\Di\Container\GetPreference;
// Manually initialising the container
$config = new Config();
$container = new Container(new GetParameters($config), new GetPreference($config));
// `get` class from container (class constructor arguments will auto-wire). The instantiated class will be cached for subsequent calls
$myInitialisedClass = $container->get(\Some\Class\To\Get::class);
use tr33m4n\Di\Config;
use tr33m4n\Di\Container;
use tr33m4n\Di\Container\GetParameters;
use tr33m4n\Di\Container\GetPreference;
// Manually initialising the container
$config = new Config();
$container = new Container(new GetParameters($config), new GetPreference($config));
// Create a new instance of a class which is not cached, with all constructor arguments auto-wired
$myInitialisedClass = $container->create(\Some\Class\To\Create::class);
// Create a new instance of a class which is not cached, with all but the `testParam` arguments auto-wired. The `testParam` will be initialised with `something`
$myInitialisedClassWithParameters = $container->create(\Some\Class\To\Create::class, ['testParam' => 'something']);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.