Caching configuration in ZF2 & Doctrine 2

289 views Asked by At

I try to build a simple application using Zend Framework 2 and Doctrine 2. I decided to use YAML config files so my doctrine.yml file is as follow:

driver:
    application_entities:
        class: 'Doctrine\ORM\Mapping\Driver\AnnotationDriver'
        cache: 'array'
        paths:
            - '__DIR__/../src/__NAMESPACE__/Entity'
    orm_default:
        drivers:
            'Application\Entity': application_entities
    authentication:
        orm_default:
            object_manager: 'Doctrine\ORM\EntityManager'
            identity_class: 'Application\Entity\User'
            identity_property: 'login'
            credential_property: 'password'
configuration:
    orm_default:
        metadata_cache: 'array'
        query_cache: 'array'

Now, the question is: is my cache config proper? And how can I verify it's actually working?

Of course I know I should use some better driver than simple array but for the moment it's enough for me.

1

There are 1 answers

0
edigu On

Doctrine provides a set of command-line tools to simplify common administration tasks such this. Here is an example list of available commands:

Doctrine Console Commands

In your case, you should use orm:ensure-production-settings command to make sure that Proxy Generation, Metadata and Query cache configurations are correct.

Assuming that you are using DoctrineORMModule to integrate doctrine with zend framework 2, open the console and simply type:

$ cd /path/to/your/projectroot
$ php public/index.php orm:ensure-production-settings

The output will warn you if the caching configuration is incorrect.

Here is the detailed official documentation for doctrine console.