我有以下问题,我将symfony放在服务器上,将它在app_dev.php debug中更改为false,在app.php中为true,现在我应该在信息php bin /控制台中获取有关我拥有的信息产品的固定版本,为什么开发人员总是向我展示?当然,调试栏将不会出现,进入URL app_dev.php / _profiler下后,我会得到一个错误
Error: Can not redeclare class Symfony\Component\Debug\ErrorHandler
但是,输入example.com/_profiler后,我得到了错误:
No route found for "GET /_profiler"
关于结果的php bin /控制台,当我将dev更改为false时,prod更改为true
Symfony
-------------------- ---------------------------------
Version 3.4.8
End of maintenance 11/2020
End of life 11/2021
-------------------- ---------------------------------
Kernel
-------------------- ---------------------------------
Type AppKernel
Name app
Environment dev
Debug true
Charset UTF-8
Root directory ./app
Cache directory ./var/cache/dev (3.0 MiB)
Log directory ./var/logs (32.0 MiB)
-------------------- ---------------------------------
PHP
-------------------- ---------------------------------
Version 5.6.33-0+deb8u1
Architecture 64 bits
Intl locale pl_PL
Timezone UTC (2018-10-07T09:30:23+00:00)
OPcache true
APCu false
Xdebug false
-------------------- ---------------------------------
我的app.php
<?php
use Symfony\Component\HttpFoundation\Request;
require __DIR__.'/../vendor/autoload.php';
if (PHP_VERSION_ID < 70000) {
include_once __DIR__.'/../var/bootstrap.php.cache';
}
$kernel = new AppKernel('prod',true);
if (PHP_VERSION_ID < 70000) {
$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);
app_dev.php
<?php
use Symfony\Component\Debug\Debug;
use Symfony\Component\HttpFoundation\Request;
// If you don't want to setup permissions the proper way, just uncomment the following PHP line
// read https://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
// for more information
//umask(0000);
// This check prevents access to debug front controllers that are deployed by accident to production servers.
// Feel free to remove this, extend it, or make something more sophisticated.
/*if (isset($_SERVER['HTTP_CLIENT_IP'])
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'], true) || PHP_SAPI === 'cli-server')
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}*/
require __DIR__.'/../vendor/autoload.php';
Debug::enable();
$kernel = new AppKernel('dev', false);
if (PHP_VERSION_ID < 70000) {
$kernel->loadClassCache();
}
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
答案 0 :(得分:0)
如果要在生产服务器或类似服务器中调试代码,我想说至少有一个黄金法则:不要修改app_dev.php或app.php。您可以像平常一样保持prod env,同时,可以在相应的环境(即'dev',您已经有'prod')和端口下运行webserver捆绑软件。如您所知,代码中的任何更改都是在dev中即时编译的,在prod中,您必须清除缓存(甚至赋予适当的Web服务器权限)。据我了解,您不希望与此有所不同,因此我建议将更改还原到app * .php脚本并相应地运行webserver捆绑软件。