petrgrishin / yiipimple
Integration dependency injection container Pimple in Yii framework
dev-master
2013-06-10 06:21 UTC
Requires
- php: >=5.3.0
- pimple/pimple: 1.0.*
This package is not auto-updated.
Last update: 2024-11-04 15:05:35 UTC
README
Integration dependency injection container Pimple in Yii framework
- Install Pimple
composer.json:
{ "require": { "petrgrishin/yiipimple": "dev-master" } }
- Change the entry scripts
Just change this
Yii::createWebApplication($config)->run();
into
Yii::createApplication('\YiiPimple\WebApplication', $config)->run();
- Configuration
return array( // ... // dipendency injection configuration 'container' => array( 'class' => '\YiiPimple\CContainer', 'services' => array( // ... put here your services ); ), // ... );
- Retrieve services
$service = Yii::app()->getContainer()->get('service');
// yii urlManager $urlManager = Yii::app()->getContainer()->get('yii.core.urlManager');