如果清除prod缓存,可以获得Doctrine Proxy的错误 [英] If clearing the prod cache, get error of Doctrine Proxy

查看:344
本文介绍了如果清除prod缓存,可以获得Doctrine Proxy的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

何时在服务器上折叠 PROD 缓存,获取错误原则代理,而在本地主机上,所有这些都执行没有错误。重置两台主机上的DEV缓存也成功重置。

 require:{
php:> = 5.3.3,
symfony / symfony:v2.7.3,
doctrine / orm:v2.5.0,
doctrine / doctrine-bundle v1.5.1,
twig / extensions:v1.3.0,
symfony / assetic-bundle:v2.3.1,
symfony / swiftmailer-bundle :v2.3.8,
symfony / monolog-bundle:v2.7.1,
sensio / distribution-bundle:v3.0.30,
sensio / framework-extra-bundle:v3.0.10,
incenteev / composer-parameter-handler:v2.1.1,
friendsofsymfony / user-bundle:v2.0.0 -alpha3,
knplabs / knp-paginator-bundle:2.5.0,
gregwar / image-bundle:v2.0.21,
sensio / buzz bundle:v1.0.0,
whiteoctober / breadcrumbs-bundle:1.2.0,
sonata-project / admin-bundle:2.3.3,
sonata-project / doctrine-orm-admin-bundle:2.3.2,
sonata-project / translation-bundle:1.0.0,
sonata-project / doctrine-extensions:1.0.2,
iphp / filestore-bundle:v0.2.5,
sonata-project / intl-bundle .2,
oro / doctrine-extensions:1.0.8,
devcookies / signgen:^ 1.0,
gedmo / doctrine-extensions ^ 2.4
},






我的观察№1



运行控制台命令清除 PROD 缓存:


sudo php app / console cache:clear -e prod


get error


PHP警告:
require(/var/www/site.com/www/app/cache/pro_/doctrine/orm /Proxies/__CG__AppMerchantBundleEntityProject.php):
无法打开流:
/var/www/site.com/www/vendor/doctrine/common/lib/Doctrine/Common/中没有此类文件或目录Proxy / AbstractProxyFactory.php
在第209行PHP致命错误:require():无法打开所需的
'/ var / www /site.com/www/app/cache/pro_/doctrine/orm/Proxies/__CG__AppMerchantBundleEntityProject.php'
(include_path ='。/ usr / share / php:/ usr / share / pear')in $第209行的b $ b /var/www/site.com/www/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php
[2016-01-29 10:30:55] php.CRITICAL:致命编译错误:
require():无法打开所需的
'/var/www/site.com/www/app/cache/pro_/doctrine/orm/Proxies/__CG__AppMerchantBundleEntityProject.php '
(include_path ='。/ usr / share / php:/ usr / share / pear')
{type:64,file:/ var / www / site.com /www/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php,line:209,level:6143,stack:[]}
{request_ip: 不可用,client_ip:不可用} PHP致命
错误:未捕获异常
'Symfony\Component\Debug\Exception\FatalErrorException'与消息
'编译错误:require():无法打开所需的
'/ var / www / site .com / www / app / cache / pro_ / doctrine / orm / Proxies / __ CG__AppMerchantBundleEntityProject.php
(include_path ='。/ usr / share / php:/ usr / share / pear' $ b /var/www/site.com/www/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php:209
堆栈跟踪:



0 {main}投在/var/www/site.com/www/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php



在线209


运行控制台命令清除 DEV 缓存:


sudo php app / console cache:clear -e dev


没关系,没有错误






我的观察№2



在配置文件中,更改设置原则

  doctrine:
dbal:
驱动程序:%database_driver%
host:%database_host%
port: %database_port%
dbname:%database_name%
用户:%database_user%
密码:%database_password%
charset:UTF8
类型:
json:Sonata\Doctrine\Types\JsonType
mapping_types:
枚举:string
orm:
auto_generate_proxy_classes:%kernel.debug%
...

更改配置:




dbal:
驱动程序:%database_driver%
主机:%database_host%
port:% $ db
$ b用户:%database_user%
密码:%database_password%
字符集:UTF8
类型:
json:Sonata\Doctrine\Types\JsonType
mapping_types:
枚举:string
orm:
auto_generate_proxy_classes:true
...

PROD缓存没有错误刷新






我的观察结果№3



最近修改的代码实际上已经打破并添加了两个相关实体:



项目实体

 <?php 

命名空间App \MerchantBundle\Entity;

使用Doctrine\ORM\Mapping作为ORM;
使用App\CoreBundle\Entity\Cashbox;
使用App\PaymentBundle\Entity\Cash\Template;
使用App \MerchantBundle\Entity\Project\Terminal;

/ **
*项目
*
* @ ORM\Table(name =merchant_projects,uniqueConstraints = {@ ORM\UniqueConstraint(name = id_UNIQUE,columns = {id}),@ ORM\UniqueConstraint(name =secret_key_UNIQUE,columns = {secret_key}),@ ORM\UniqueConstraint(name =merchant_id_UNIQUE,columns = { merchant_id})})
* @ ORM\Entity
* /
class Project
{

...

/ **
* @ ORM\OneToMany(targetEntity =\App\MerchantBundle\Entity\Project\Domain,mappedBy =project)
* /
private $ domains;
...

实体

 <?php 

命名空间App \MerchantBundle\Entity\Project;

使用Doctrine\ORM\Mapping作为ORM;

/ **
*域
*
* @ ORM\Table(name =merchant_project_domains)
* @ ORM\Entity
* /
class Domain
{
...

/ **
* @var \App\MerchantBundle\Entity \Project
*
* @ ORM\ManyToOne(targetEntity =\App\MerchantBundle\Entity\Project,inversedBy =domains)
* @ ORM\\ \\ JoinColumns({
* @ ORM\JoinColumn(name =project_id,referencedColumnName =id)
*})
* /
private $ project;

如果您删除连接域实体

  / ** 
* @var \App\MerchantBundle\Entity\Project
* /
private $ project;

没关系,没有错误

解决方案

你尝试强制删除缓存

  rm -rf app / cache / * 

然后(当然db dump它会很好)

  php app / console doctrine:schema:update --force 


When to fold PROD cache on the server get the error Doctrine Proxy, while on the local host, all performed without error. Reset DEV cache on both hosts also successfully reset.

"require": {
    "php": ">=5.3.3",
    "symfony/symfony": "v2.7.3",
    "doctrine/orm": "v2.5.0",
    "doctrine/doctrine-bundle": "v1.5.1",
    "twig/extensions": "v1.3.0",
    "symfony/assetic-bundle": "v2.3.1",
    "symfony/swiftmailer-bundle": "v2.3.8",
    "symfony/monolog-bundle": "v2.7.1",
    "sensio/distribution-bundle": "v3.0.30",
    "sensio/framework-extra-bundle": "v3.0.10",
    "incenteev/composer-parameter-handler": "v2.1.1",
    "friendsofsymfony/user-bundle": "v2.0.0-alpha3",
    "knplabs/knp-paginator-bundle": "2.5.0",
    "gregwar/image-bundle": "v2.0.21",
    "sensio/buzz-bundle": "v1.0.0",
    "whiteoctober/breadcrumbs-bundle": "1.2.0",
    "sonata-project/admin-bundle": "2.3.3",
    "sonata-project/doctrine-orm-admin-bundle": "2.3.2",
    "sonata-project/translation-bundle": "1.0.0",
    "sonata-project/doctrine-extensions": "1.0.2",
    "iphp/filestore-bundle" : "v0.2.5",
    "sonata-project/intl-bundle": "2.2.2",
    "oro/doctrine-extensions": "1.0.8",
    "devcookies/signgen": "^1.0",
    "gedmo/doctrine-extensions": "^2.4"
},


My observations №1

Run the console command for clearing PROD cache:

sudo php app/console cache:clear -e prod

get error

PHP Warning: require(/var/www/site.com/www/app/cache/pro_/doctrine/orm/Proxies/__CG__AppMerchantBundleEntityProject.php): failed to open stream: No such file or directory in /var/www/site.com/www/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php on line 209 PHP Fatal error: require(): Failed opening required '/var/www/site.com/www/app/cache/pro_/doctrine/orm/Proxies/__CG__AppMerchantBundleEntityProject.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/site.com/www/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php on line 209 [2016-01-29 10:30:55] php.CRITICAL: Fatal Compile Error: require(): Failed opening required '/var/www/site.com/www/app/cache/pro_/doctrine/orm/Proxies/__CG__AppMerchantBundleEntityProject.php' (include_path='.:/usr/share/php:/usr/share/pear') {"type":64,"file":"/var/www/site.com/www/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php","line":209,"level":6143,"stack":[]} {"request_ip":"unavailable","client_ip":"unavailable"} PHP Fatal error: Uncaught exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Compile Error: require(): Failed opening required '/var/www/site.com/www/app/cache/pro_/doctrine/orm/Proxies/__CG__AppMerchantBundleEntityProject.php' (include_path='.:/usr/share/php:/usr/share/pear')' in /var/www/site.com/www/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php:209 Stack trace:

0 {main} thrown in /var/www/site.com/www/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php

on line 209

Run the console command for clearing DEV cache:

sudo php app/console cache:clear -e dev

It's all right, and no errors


My observations №2

When in the configuration file, change the setting Doctrine

doctrine:
dbal:
    driver:   "%database_driver%"
    host:     "%database_host%"
    port:     "%database_port%"
    dbname:   "%database_name%"
    user:     "%database_user%"
    password: "%database_password%"
    charset:  UTF8
    types:
        json: Sonata\Doctrine\Types\JsonType
    mapping_types:
        enum: string
orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    ...

Changed config:

doctrine:
dbal:
    driver:   "%database_driver%"
    host:     "%database_host%"
    port:     "%database_port%"
    dbname:   "%database_name%"
    user:     "%database_user%"
    password: "%database_password%"
    charset:  UTF8
    types:
        json: Sonata\Doctrine\Types\JsonType
    mapping_types:
        enum: string
orm:
    auto_generate_proxy_classes: true
    ...

PROD cache is flushed without an error


My observations №3

The recent amendments of code that actually all broken and added two related entities:

Project entity

<?php

namespace App\MerchantBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use App\CoreBundle\Entity\Cashbox;
use App\PaymentBundle\Entity\Cash\Template;
use App\MerchantBundle\Entity\Project\Terminal;

/**
 * Project
 *
 * @ORM\Table(name="merchant_projects", uniqueConstraints={@ORM\UniqueConstraint(name="id_UNIQUE", columns={"id"}), @ORM\UniqueConstraint(name="secret_key_UNIQUE", columns={"secret_key"}), @ORM\UniqueConstraint(name="merchant_id_UNIQUE", columns={"merchant_id"})})
 * @ORM\Entity
 */
class Project
{

    ...

    /**
     * @ORM\OneToMany(targetEntity="\App\MerchantBundle\Entity\Project\Domain", mappedBy="project")
     */
    private $domains;
    ...

And Domain entity

<?php

namespace App\MerchantBundle\Entity\Project;

use Doctrine\ORM\Mapping as ORM;

/**
 * Domain
 *
 * @ORM\Table(name="merchant_project_domains")
 * @ORM\Entity
 */
class Domain
{
    ...

    /**
     * @var \App\MerchantBundle\Entity\Project
     *
     * @ORM\ManyToOne(targetEntity="\App\MerchantBundle\Entity\Project", inversedBy="domains")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="project_id", referencedColumnName="id")
     * })
     */
    private $project;

If you remove a connection Domain entity

    /**
     * @var \App\MerchantBundle\Entity\Project
     */
    private $project;

It's all right, and no errors

解决方案

Did you try force remove cache by

rm -rf app/cache/*

and then (of course db dump it will be nice)

php app/console doctrine:schema:update --force

这篇关于如果清除prod缓存,可以获得Doctrine Proxy的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆