1. Go to this page and download the library: Download istok/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/ */
istok / container example snippets
// Registration of cachable entry
Container::singletone(string $id, string|\Closure $defitition);
// This entry will not be cached
Container::register(string $id, string|\Closure $defitition);
// parameter $name of $for::__construct() will be resolved by given closure
Container::argument(string $name, string $for, \Closure $resolver);
// take instance
Container::make(string $id);
/**
* Call $fn with given arguments, using Container::make() for rest
* @param array<string, mixed> $args
*/
Container::call(\Closure $fn, $args);
/**
* Psalm-friendly version, contains actual type check, T should be class or interface, result should be typeof T
* @template T
* @param class-string<T> $id
* @return T
*/
Container::construct(string $id): object;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.