Yii 1.1: doctrine2orm

An extensions that implements Doctrine 2 ORM functionality
11 followers

Doctrine 2 ORM Extension ΒΆ

NOTE

Please note this has been developed with Doctrine 2.0+, work is underway to ensure 2.1+ compatibility

Overview

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.

Installation

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.

Usage

Once installed and configured, you can then use the extension like any other component by accessing it through and application instance;

Yii::app()->doctrine

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.

Yii::app()->doctrine->getConnection();
Yii::app()->doctrine->getCache();

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

Be the first person to leave a comment

Please to leave your comment.

Create extension