If clearing the prod cache, get error of Doctrine Proxy
<p>When to fold <strong>PROD</strong> cache on the <strong>server</strong> get the error Doctrine Proxy, while on the <strong>local</strong> host, all performed without error. Reset DEV cache on both hosts also successfully reset.</p>

<pre><code>"require": {
    "php": "&gt;=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"
},
</code></pre>

<hr>

<p><strong>My observations №1</strong></p>

<p>Run the console command for clearing <strong>PROD</strong> cache:</p>

<blockquote>
  <p>sudo php app/console cache:clear -e prod</p>
</blockquote>

<p>get error</p>

<blockquote>
  <p>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:</p>
  
  <h1>0 {main}   thrown in /var/www/site.com/www/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php</h1>
  
  <p>on line 209</p>
</blockquote>

<p>Run the console command for clearing <strong>DEV</strong> cache:</p>

<blockquote>
  <p>sudo php app/console cache:clear -e dev</p>
</blockquote>

<p>It's all right, and no errors</p>

<hr>

<p><strong>My observations №2</strong></p>

<p>When in the configuration file, change the setting Doctrine</p>

<pre><code>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%"
    ...
</code></pre>

<p>Changed config:</p>

<pre><code>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
    ...
</code></pre>

<p><strong>PROD cache is flushed without an error</strong></p>

<hr>

<p><strong>My observations №3</strong></p>

<p>The recent amendments of code that actually all broken and added two related entities:</p>

<p><strong>Project</strong> entity</p>

<pre><code>&lt;?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;
    ...
</code></pre>

<p>And <strong>Domain</strong> entity</p>

<pre><code>&lt;?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;
</code></pre>

<p>If you remove a connection Domain entity</p>

<pre><code>    /**
     * @var \App\MerchantBundle\Entity\Project
     */
    private $project;
</code></pre>

<p>It's all right, and no errors</p>