Closure anonymous function in php
<?php
// add sessions
$di->add("session", function() {
return new Session();
});
// add cache
$di->add("cache", function() {
return new Cache();
});
// add class which will be used in any request
$di->add("anyTimeCalledClass", new SomeClass());
// example with usage params, and next variables
$di->add("myName", function($params) use($application) {
$application->myMethod($params);
});