3

I'm trying to set up the Symfony CMF with Doctrine PHPCR-ODM. Unfortunately, whenever I want to save some data from Sonata Admin into the database, I get the following exception:

Compile Error: Doctrine\Common\Proxy\AbstractProxyFactory::getProxyDefinition():
    Failed opening required 
    '/Applications/XAMPP/xamppfiles/htdocs/app/cache/dev/doctrine/PHPCRProxies/__CG__DoctrineODMPHPCRDocumentGeneric.php'

I have initialized the repository multiple times and deleted the cache too, but nothing helped.

Does anybody have an idea, why this file is missing? How could this file being generated?

temparus
  • 119
  • 3
  • 10

1 Answers1

2

I found out what the problem was.

In the config file of Symfony2, I had to add the following:

doctrine_phpcr:
    odm:
        auto_generate_proxy_classes: "%kernel.debug%"

For Production environment,you have to call php app/console cache:warmup to generate the proxy classes for the documents in advance.

It should be done like this to minimize the work in the production environment.

temparus
  • 119
  • 3
  • 10
  • 2
    before that you should run 1 - `php app/console cache:clear --env=prod --no-debug` and 2 - `php app/console cache:warmup --env=prod --no-debug` link - http://symfony.com/doc/current/cookbook/deployment/tools.html – Sumeet Jul 16 '15 at 12:29
  • if you followed a documentation on symfony.com and that step is missing or unclear, we appreciate an issue (or even a pull request?) with improvements to https://github.com/symfony-cmf/symfony-cmf-docs – dbu Jul 17 '15 at 08:55
  • I started my project from scratch and configured all required bundles by myself. I just overlooked this section of the docs: http://symfony.com/doc/current/cmf/bundles/phpcr_odm/introduction.html#doctrine-phpcr-odm-configuration – temparus Jul 17 '15 at 18:45