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

醉酒当歌 提交于 2019-12-20 17:36:09

问题


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.


回答1:


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



回答2:


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


来源:https://stackoverflow.com/questions/36255440/symfony-cache-doctrine-orm-proxies-failed-to-open-stream-proxy-abstractproxyfac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!