Symfony2生产错误的“ 404”

问题描述 投票:2回答:1

我正在尝试将开发环境从生产更改为生产。 当我尝试使用prod env进行无效路由时,出现dev错误页面“ NotFoundHttpException:”,而不是prod错误页面,例如“ e-mail us ...”。

有我的app.php:

use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\Request;

$loader = require_once __DIR__.'/../app/bootstrap.php.cache';

// Use APC for autoloading to improve performance.
// Change 'sf2' to a unique prefix in order to prevent cache key conflicts
// with other applications also using APC.
/*
$apcLoader = new ApcClassLoader('sf2', $loader);
$loader->unregister();
$apcLoader->register(true);*/

require_once __DIR__.'/../app/AppKernel.php';
require_once __DIR__.'/../app/AppCache.php';

$kernel = new AppKernel('prod', true);
$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);

有任何想法吗 ?

谢谢阿德里安

symfony http-status-code-404 production-environment
1个回答
3
投票

您的app.php文件包含new AppKernel('prod', true) 。 构造函数的第二个参数确定它是否处于调试模式。 第一个参数仅确定名称,该名称可在加载特定于环境的配置文件时使用。

只要启用了调试,错误页面就会显示详细版本,其中包含大量信息,可帮助您调试应用程序。 在生产中,永远不要启用调试,而要将其设置为false (这也是标准版中的默认设置):

// ...
$kernel = new AppKernel('prod', false);
// ...
© www.soinside.com 2019 - 2024. All rights reserved.