我有基于 Symfony2 框架的应用程序。我已经转移到生产环境,网站运行良好(我正在尝试调整缓存 - 在我的主机上是 xcache)。但突然我有这个错误:
致命错误:未捕获的异常 'Doctrine\Common\Annotations\AnnotationException' 带有消息“您必须启用 opcache.save_comments=1 或 zend_optimizerplus.save_comments=1。” 在 /nfsmnt/hosting2_1/6/9/699be0da-dfbd-4651-90de-448d295bb741/playsport.sk/web/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php:183 堆栈跟踪:#0 /nfsmnt/hosting2_1/6/9/699be0da-dfbd-4651-90de-448d295bb741/playsport.sk/web/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php(162): Doctrine\Common\ Annotations\AnnotationException::optimizerPlusSaveComments()
1 /nfsmnt/hosting2_1/6/9/699be0da-dfbd-4651-90de-448d295bb741/playsport.sk/web/app/cache/prod/appProdProjectContainer.php(237):
Doctrine\Common\Annotations\AnnotationReader->__construct() #2 /nfsmnt/hosting2_1/6/9/699be0da-dfbd-4651-90de-448d295bb741/playsport.sk/web/app/bootstrap.php.cache(2103): appProdProjectContainer->getAnnotationReaderService() #3 /nfsmnt/hosting2_1/6/9/699be0da-dfbd-4651-90de-448d295bb741/playsport.sk/web in /nfsmnt/hosting2_1/6/9/699be0da-dfbd-4651-90de-第 183 行的 448d295bb741/playsport.sk/web/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php
我无法在我的主机上启用 opcache.save_comments(我没有特权,这是临时付费托管服务)。因此,我禁用了 prod 环境中的所有缓存并尝试重新运行网站。我目前的配置:
网络/应用程序.php:
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
// Enable APC for autoloading to improve performance.
// You should change the ApcClassLoader first argument to a unique prefix
// in order to prevent cache key conflicts with other applications
// also using APC.
//$apcLoader = new ApcClassLoader(sha1(__FILE__), $loader);
//$xcacheLoader = new \Symfony\Component\ClassLoader\XcacheClassLoader(sha1(__FILE__) . "PlaySport", $loader);
//$loader->unregister();
//$xcacheLoader->register(true);
require_once __DIR__.'/../app/AppKernel.php';
// require_once __DIR__.'/../app/AppCache.php';
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
//$kernel = new AppCache($kernel);
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
//Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
config_prod.yml:
imports:
- { resource: config.yml }
#framework:
# validation:
# cache: xcache
#doctrine:
# orm:
# metadata_cache_driver: xcache
# result_cache_driver: xcache
# query_cache_driver: xcache
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
console:
type: console
我真的不知道该怎么办。仍然像以前一样出错。如何禁用 Doctrine 中的注释缓存或该问题的任何其他解决方案。谢谢!