yiipimple Integration dependency injection container Pimple in Yii framework

  1. Integration dependency injection container Pimple in Yii framework
  2. Require
  3. Resources

Integration dependency injection container Pimple in Yii framework

1) Install Pimple

composer.json:

[javascript]
{
  "require": {
    "petrgrishin/yiipimple": "dev-master"
  }
}

2) Change the entry scripts

Just change this

Yii::createWebApplication($config)->run();

into

Yii::createApplication('\YiiPimple\WebApplication', $config)->run();

3) Configuration

return array(
    // ...
    // dipendency injection configuration
    'container' => array(
        'class' => '\YiiPimple\CContainer',
        'services' => array(
            // ... put here your services
        );
    ),
    // ...
);

4) Retrieve services

$service = Yii::app()->getContainer()->get('service');
// yii urlManager
$urlManager = Yii::app()->getContainer()->get('yii.core.urlManager');

Require

  • PHP >=5.3.0
  • Pimple 1.0.*

Resources

Project on github.com

1 0
3 followers
0 downloads
Yii Version: Unknown
License: MIT
Category: Others
Developed by: Petr.Grishin
Created on: Jun 10, 2013
Last updated: 4 years ago

Related Extensions