Symfony Cache 学说/orm/Proxies 未能在第 209 行打开流/Proxy/AbstractProxyFactory.php

2022-01-16 00:00:00 php symfony doctrine doctrine-orm

我正在尝试将 symfony 移动到共享主机.

I'm try to move symfony to shared host.

我将 symfony 结构移到/并且我的 web 文件夹是/public_html.

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

警告:需要(/home/user/app/cache/prod/doctrine/orm/Proxies/__CG__UserBundleEntityUser.php):无法打开流:/home/user/vendor/doctrine/common 中没有这样的文件或目录/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php 第 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

警告:需要(/home/user/app/cache/prod/doctrine/orm/Proxies/__CG__UserBundleEntityUser.php):无法打开流:/home/user/vendor/doctrine/common 中没有这样的文件或目录/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php 第 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

致命错误:require(): 无法打开所需的 '/home/user/app/cache/prod/doctrine/orm/Proxies/__CG__UserBundleEntityUser.php' (include_path='.:/opt/php55/lib/php') 在/home/user/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php 第 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

此错误仅发生在 prod 环境中.dev 环境中不会引发异常.

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

我尝试了以下方法:

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

我使用 Symfony 2.8.3.以下目录存在于本地和服务器上:

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

本地缓存:-/annotations,/twig,/vich_uploader +/doctrine,/translations

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

服务器缓存:-/annotations,/twig,/vich_uploader

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

如果我将本地缓存上传到服务器,异常就会消失.

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

推荐答案

您在尝试访问应用程序之前没有创建代理类.这通常由以下人员完成:

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

prod 环境中默认禁用代理类的自动生成.您可以通过将其添加到您的配置来启用类似于 dev 环境的代理类的自动生成:

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

相关文章