$request
$request : \PhalApi_Request
request
Dependence Injection Class
Dependency Injection Container
Usage:
$di = new PhalApi_DI();
// setter/getter, magic method like setX/getX, class property like $di->X, array like $di['X']
$di->key = 'value';
$di['key'] = 'value';
$di->set('key', 'value');
$di->setKey('value');
echo $di->key;
echo $di['key'];
echo $di->get('key');
echo $di->getKey();
// ways to initialize: assign directly, or by class name(will call onInitialize method), or by anonymous function
$di->simpleKey = array('value');
$di->classKey = 'PhalApi_DI';
$di->closureKey = function () {
return 'sth heavy ...';
};
Default Services:
$instance : \PhalApi_DI
get(string $key, mixed $default = NULL) : mixed
Getter
string | $key | service name, unique, case sensitive |
mixed | $default | service default value |
return NULL when service not exists