简体   繁体   English

Symfony将开发人员更改为产品

[英]Symfony change dev to prod

I have the following problem, I put symfony on the server, I changed it in app_dev.php debug on false, and in app.php on true and now I should in information php bin/console about get information that I have a set version of prod, why does dev show me all the time? 我有以下问题,我将symfony放在服务器上,将它在app_dev.php调试中更改为false,在app.php中更改为true,现在我应该在信息php bin /控制台中获取有关我拥有固定版本的信息产品,为什么开发人员总是向我展示? Of course, the debug bar will not appear, and after going under the url app_dev.php/_profiler I get an error 当然,调试栏将不会出现,并且进入URL app_dev.php / _profiler下后,我得到一个错误

Error: Can not redeclare class Symfony\Component\Debug\ErrorHandler

however, after entering example.com/_profiler I get the error: 但是,输入example.com/_profiler后,出现错误:

No route found for "GET /_profiler"

php bin/console about result, when i change dev to false, prod to true 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
 -------------------- ---------------------------------

my app.php 我的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_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);

If you want to debug code in a production server, or something similar, I'd say there's at least a golden rule: Don't modify app_dev.php nor app.php. 如果要在生产服务器或类似服务器中调试代码,我想说至少有一条黄金法则:不要修改app_dev.php或app.php。 You can keep your prod env as usual, and meanwhile, you can run the webserver bundle with the corresponding environment (ie 'dev', you already have 'prod') and port. 您可以像往常一样保持prod env,同时,可以在相应的环境(即'dev',您已经具有“ prod”)和端口下运行Webserver捆绑软件。 As you surely know, any changes in the code are compiled on-the-fly in dev, and in prod you have to clear the cache (and even give the proper webserver permissions). 如您所知,代码中的任何更改都是在dev中即时编译的,在prod中,您必须清除缓存(甚至赋予适当的Web服务器权限)。 As far as I've understood, you don't want anything different to this, so I suggest revert the changes to the app*.php scripts and run the webserver bundle accordingly. 据我了解,您不希望与此有所不同,因此我建议将更改还原到app * .php脚本并相应地运行webserver捆绑软件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM