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.
Now, if you think that this article was interesting don't forget to rate it. It shows me that you care and thus I will continue write about these things.
Eugen Mihailescu
Latest posts by Eugen Mihailescu (see all)
- Dual monitor setup in Xfce - January 9, 2019
- Gentoo AMD Ryzen stabilizator - April 29, 2018
- Symfony Compile Error Failed opening required Proxies - January 22, 2018
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
```
Hi, thanks for pointing this out. Hawk eye!.