Phalcon 1.2.4 (PHP Framwork)::DIコンテナ&モジュール設定
Phalcon Framework
DIコンテナ&モジュール設定
http://docs.phalconphp.com/en/latest/reference/di.html
■基本
Phalcon\DI コンポーネント
<?php $di = new Phalcon\DI\FactoryDefault();
サービス登録方法
$di->set('{Service Name}', function() { return new ServiceClass(); });
サービス呼び出し方法
$variable = Phalcon\DI::getDefault()->get('{Service Name}');
定義されている主なサービス名
http://docs.phalconphp.com/en/latest/reference/di.html#service-name-conventions
- dispatcher
- router
- url
- request
- response
- cookies
- filter
- flash
- flashSession
- session
- eventsManager
- db
- security
- crypt
- tag
- escaper
- annotations
- modelsManager
- modelsMetadata
- transactionManager
- modelsCache
- viewsCache
※もちろん、これ以外にも、サービス登録、呼び出しはできます。