25
votes

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 ... - Nicolai Fröhlich
yes, i run. This no return error, return message warmup generate. But the folder doctrine is mission in app/cache/prod. - Luiz Brz Developer
I provided an answer that will resolve the issue. Enable automatic proxy class generation in your configuration for the prod environment. - Nicolai Fröhlich

3 Answers

75
votes

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
0
votes

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
0
votes

/app/config/doctrine.yml

Change from:

  orm:
    auto_generate_proxy_classes: "%kernel.debug%"

To:

  orm:
    auto_generate_proxy_classes: true

Works!