Doctrine 2 ORM Extension ¶
Please note this has been developed with Doctrine 2.0+, work is underway to ensure 2.1+ compatibility
This extension sets up Doctrine 2 ORM for use in your application. It also adds support for the Doctrine 2 CLI tool via the yiic menu.
1 . Download and unzip the latest extension from the project download page to your extensions directory. It should then have the following structure;
protected/ - extensions/ - Wildkat/ - YiiExt/ - DoctrineOrm/ | - vendor/ | - docs/ | - commands/ | - config/
2 . Move the DoctrineOrmCommand.php from the extensions commands directory to your applications protected/commands directory.
3 . You will then need to download the latest Doctrine 2 library and ensure each package fits inside the vendor directory like this;
- vendor/ | - Doctrine/ | | - Common/ | | - DBAL/ | | - ORM/ | - Symfony/
4 . Configure your main.php and console.php configuration files. You must add the doctrine configuration to the component section for each config file. The component takes the parameters (dbal, cache and entityManager) which specify a single or multiple component. An example for the config files can be found the the config folder inside the extension directory.
There is full documentation on each configuration option inside the docs directory of the extension. The component class is also fully documented.
Once installed and configured, you can then use the extension like any other component by accessing it through and application instance;
To obtain an entity manager, simple call getEntityManager providing an optional configuration name or leave empty for the 'default' configuration.
Yii::app()->doctrine->getEntityManager() // Returns Doctrine\ORM\EntityManager
If you would simply like to obtain a cache or connection instance, you can do so in the same way.
You can also access the Doctrine CLI tool by using the yiic command where you will see the doctrineorm option listed in the menu.
Please report bug and enhancements to the issue section of the project page