Luiz Luiz - 9 days ago 6
PHP Question

Symfony Cache doctrine/orm/Proxies failed to open stream /Proxy/AbstractProxyFactory.php on line 209

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.

Answer

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
Comments