【发布时间】:2021-08-02 09:06:22
【问题描述】:
我对这种行为感到很困惑。 我将我的环境设置为生产环境,调试器在生产环境中仍然可用。
我的 .env 文件是这样的
APP_ENV=production
这是我的 Bundles 配置。
<?php
$bundles = [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle::class => ['all' => true],
];
if ('dev' === $_SERVER['APP_ENV']) {
$devBundles = [
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true]
];
return array_merge($bundles, $devBundles);
}
return $bundles;
有人知道为什么我的 Debug 仍在生产吗?
例如:
http://localhost/asd/
返回 Symfony 输出错误..
ResourceNotFoundException NotFoundHttpException 未找到 HTTP 404 找不到“GET /asd/”的路由
感谢任何帮助。
编辑:我不确定这是否有帮助,但这是我发现的。
如果我将APP_EVN 设置为dev
我的 WebProfilerBundle 正在加载,如果我将其设置为 production 后它不会加载。
【问题讨论】:
-
服务器上是否有
.env.local文件? -
不,我的服务器上没有。
-
您尝试过什么来解决问题?你被困在哪里了?是否有任何其他配置可以设置
APP_ENV? -
没有其他设置是 APP_ENV,这就是我感到困惑的原因。我只有在 .env 文件中。
-
你试过
APP_ENV=prod吗?
标签: php symfony environment-variables