0
votes

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? Of course, the debug bar will not appear, and after going under the url app_dev.php/_profiler I get an error

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

however, after entering example.com/_profiler I get the error:

No route found for "GET /_profiler"

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

    <?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);
1
Can you show your app_dev.php and your app.php? also your AppKernel, please.fgamess
@FranckGamess i edit my first postPawelC
Thanks. You ran php bin/console in the prod server ?fgamess
Yes, i don't have any problemPawelC
Ok because the output is saying that you are in dev environment. Is it the expected behavior?fgamess

1 Answers

1
votes

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. You can keep your prod env as usual, and meanwhile, you can run the webserver bundle with the corresponding environment (i.e. 'dev', you already have 'prod') and port. 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). 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.