Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony将开发更改为产品_Php_Symfony - Fatal编程技术网

Php Symfony将开发更改为产品

Php Symfony将开发更改为产品,php,symfony,Php,Symfony,我有以下问题,我把symfony放在服务器上,我在app_dev.php debug中把它改为false,在app.php中改为true,现在我应该在信息php bin/console中获得关于我有一套prod版本的信息,为什么dev总是显示给我?当然,调试栏不会出现,在url app_dev.php//u profiler下出现错误 Error: Can not redeclare class Symfony\Component\Debug\ErrorHandler 但是,在进入exampl

我有以下问题,我把symfony放在服务器上,我在app_dev.php debug中把它改为false,在app.php中改为true,现在我应该在信息php bin/console中获得关于我有一套prod版本的信息,为什么dev总是显示给我?当然,调试栏不会出现,在url app_dev.php//u profiler下出现错误

Error: Can not redeclare class Symfony\Component\Debug\ErrorHandler
但是,在进入example.com//u profiler后,我得到一个错误:

No route found for "GET /_profiler"
php bin/console关于结果,当我将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或app.php。您可以像往常一样保持prod env,同时,您可以使用相应的环境(即“dev”,您已经有了“prod”)和端口运行webserver包。您肯定知道,代码中的任何更改都是在dev中动态编译的,而在prod中,您必须清除缓存(甚至授予适当的web服务器权限)。据我所知,您不希望与此有任何不同,因此我建议恢复对app*.php脚本的更改,并相应地运行Web服务器包。

能否显示您的app_dev.php和app.php?还有你的应用内核。@frankgames我编辑了我的第一篇博文谢谢。您在prod服务器中运行了php bin/console?是的,我没有任何问题OK,因为输出表明您在开发环境中。这是预期的行为吗?在这种情况下,如何将应用程序从dev切换到prod?例如,在htaccess中,我将所有请求设置为通过app.php,而不是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);