30

I'm try to move symfony to shared host.

I moved symfony structure to / and my web folder is /public_html.

Warning: require(/home/user/app/cache/prod/doctrine/orm/Proxies/__CG__UserBundleEntityUser.php): failed to open stream: No such file or directory in /home/user/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php on line 209

Warning: require(/home/user/app/cache/prod/doctrine/orm/Proxies/__CG__UserBundleEntityUser.php): failed to open stream: No such file or directory in /home/user/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php on line 209

Fatal error: require(): Failed opening required '/home/user/app/cache/prod/doctrine/orm/Proxies/__CG__UserBundleEntityUser.php' (include_path='.:/opt/php55/lib/php') in /home/user/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php on line 209

This error occurs only in the prod environment. The exception is not thrown in the dev environment.

I tried the following:

rm -rf /app/cache + chmod 777
app/console cache:warmup

I use Symfony 2.8.3. The following directories are present locally and on the server:

LOCAL CACHE: - /annotations, /twig, /vich_uploader + /doctrine, /translations

SERVER CACHE: - /annotations, /twig, /vich_uploader

If I upload my local cache to the server, the exception disappears.

3
  • did you run app/console cache:warmup --env=prod ? This command generated the proxy caches actually ... Commented Mar 28, 2016 at 12:25
  • yes, i run. This no return error, return message warmup generate. But the folder doctrine is mission in app/cache/prod. Commented Mar 28, 2016 at 12:30
  • I provided an answer that will resolve the issue. Enable automatic proxy class generation in your configuration for the prod environment. Commented Mar 28, 2016 at 12:32

3 Answers 3

84

You did not create the proxy classes before you tried to access your application. This is usually done by:

app/console cache:warmup --env=prod

The auto-generation of proxy-classes is disabled by default in the prod environment. You can enable automatic generation of proxy-classes similar to the dev environment by adding this to your config:

app/config/config_prod.yml

doctrine:
    orm:
        auto_generate_proxy_classes:  true # <- change to true
        proxy_dir:            '%kernel.cache_dir%/doctrine/orm/Proxies'
        proxy_namespace:      Proxies
Sign up to request clarification or add additional context in comments.

7 Comments

This solved the problem. Before my config have only this auto_generate_proxy_classes: "%kernel.debug%". Thanks
There's a typo on the first line, it's doctrine: :)
"The auto-generation of proxy-classes is disabled by default in the prod environment" why is that? should i let it enabled forever or disabled it again?
If auto_generate_proxy_classes is on, it will generate the proxy files on each request! You want that in development so you have not to do this manually each time you change something. You don't want this in production because it will kill your server at a certain amount of requests (which happened to a product I worked on at around 1k requests per second ;)
@itinance I suggest to read this Doctrine Cookbook for advanced configuration, as it explains it in detail much better then I could :)
|
1

/app/config/doctrine.yml

Change from:

  orm:
    auto_generate_proxy_classes: "%kernel.debug%"

To:

  orm:
    auto_generate_proxy_classes: true

Works!

Comments

-1

I have changed all files that refer to the expression 'auto_generate_proxy_classes' (I've changed the value from 'false' to 'true') and this fixed the issue:

  1. ... /vendor/doctrine/doctrine-bundle/DoctrineBundle.php
  2. ... /vendor/doctrine/doctrine-bundle/Resources/doc/configuration.rst
  3. ... /vendor/doctrine/doctrine-bundle/DependencyInjection/Configuration.php
  4. ... /vendor/doctrine/doctrine-bundle/DependencyInjection/DoctrineExtension.php
  5. ... /app/config/config.php
  6. ... /app/cache/prod/appProdProjectContainer.php

1 Comment

you should never change files in /vendor

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.