Scheduled maintenance — back soon.

~/blog/symfony-compile-error-failed-opening-required-proxies

Symfony Compile Error Failed opening required Proxies

While testing a Symfony web application in production environment (--env=prod) I encountered an odd exception which more or less was triggered with each request:

Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalErrorException: Compile Error: require(): Failed opening required 'var/cache/prod/doctrine/orm/Proxies/__CG__some-file.php' (include_path='.:/usr/share/php7:/usr/share/php') at vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php line 223

First I should clarify few things:

  • my Symfony v3.4.4 application defines few Doctrine ORM entities which are configured to use the ORM Cache via @ORM\Cache annotation

  • the application configuration (see config.yml) defines the options doctrine.orm.entity_managers.{metadata_cache_driver,query_cache_driver,result_cache_driver,second_level_cache}

In order to fix this the first thing I tried was to clear the cache for the production environment:

bin/console cache:clear --env=prod

but unfortunately this didn't fix the problem. The I removed the var/cache/prod folder manually and I just let the application to recreate the cache by itself. It also dind't work. The only thing that seemed to work was to warm-up the cache forcibly by running the following command:

bin/console cache:clear --env=prod --no-debug bin/console cache:warmup --env=prod --no-debug

Please note that this problem never occurred in development environment.

Comments

2 comments

  • Bastien Ho

    Hi, thank you for this tip! anyway, just a mistake in your code : ``` bin/console cache:warmup --env-prod --no-debug ``` should be: ``` bin/console cache:warmup --env=prod --no-debug ```

Leave a comment

Name and email required · moderated before publish · plain text only