简体   繁体   English

我无法在生产中关闭 Laravel 中的调试栏

[英]I can't turn off debug bar in Laravel on production

I have set我已经设置

'enabled' = false

in both package and in config/debugbar.php在包和 config/debugbar.php 中

I cleared cache with我清除了缓存

php artisan cache:clear

but I still see it on production environment.但我仍然在生产环境中看到它。 I accidently commited我不小心犯了

'enabled' = false

by accident and can't turn it off.不小心,无法关闭它。 I even rolled back commits, but that doesn't help.我什至回滚了提交,但这无济于事。 Any ideas?有什么想法吗?

@edit the .env has also debug set to false @edit .env 也将调试设置为 false

@edit2 also when I got ot /login route on new browser (or private mode) I don't see the bar, but when I refresh this page, it is there again @edit2 也当我在新浏览器(或私有模式)上获得 ot /login 路由时,我看不到栏,但是当我刷新此页面时,它又出现了

It is not a matter of debugbar, it is general problem with .env.这不是调试栏的问题,而是 .env 的一般问题。 You can change your APP_NAME to see that it is not changing anything.您可以更改您的 APP_NAME 以查看它没有改变任何内容。

To apply your new config changes including .env changes you need to run artisan command in your project folder:要应用包括 .env 更改在内的新配置更改,您需要在项目文件夹中运行 artisan 命令:

php artisan config:cache

Go To .env And Set转到.env并设置

DEBUGBAR_ENABLED=false

OR

APP_DEBUG=false

Did u try changing it in the .env file?您是否尝试在 .env 文件中更改它?

Look for the value APP_DEBUG in the .env file and set it false .在 .env 文件中查找值APP_DEBUG并将其设置为false

Out of the box, .env has it set to true .开箱即用, .env 将其设置为true

Solution for 5.5 and above 5.5及以上解决方案

Install the package with:安装包:

composer require barryvdh/laravel-debugbar:dev-master

Because of the package auto-discovery feature, you don't need to add package's service provider to the providers list in config/app.php and Debugbar will only be loaded in the development environment.由于包自动发现功能,您不需要将包的服务提供者添加到config/app.phpproviders列表中,Debugbar 只会在开发环境中加载。

Solution for 5.4 and below 5.4及以下的解决方案

Put this code to the AppServiceProvider@register :将此代码放入AppServiceProvider@register

if ($this->app->isLocal()) {
    $this->app->register('Barryvdh\Debugbar\ServiceProvider');
}

Don't forget to remove Laravel Debugbar line from config/app.php providers section.不要忘记从config/app.php providers 部分中删除 Laravel Debugbar 行。

After doing this, Laravel Debugbar will only be loaded in a local environment.这样做之后,Laravel Debugbar 将只会在本地环境中加载。

if you are on 5.4 you can do under AppServiceProvider as follows:如果您使用的是 5.4,则可以在 AppServiceProvider 下进行如下操作:

public function register()
{
/*
 * Sets third party service providers that are only needed on local/testing environments
 */
if ($this->app->environment() != 'production') {
/**
 * Loader for registering facades.
 */
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
/*
 * Load third party local aliases
 */
$loader->alias('Debugbar', \Barryvdh\Debugbar\Facade::class);
}
}

if you want full control under 5.5 you can do in the same AppServiceProvider:如果你想在 5.5 下完全控制你可以在同一个 AppServiceProvider 中做:

public function register()
{
    /*
     * Sets third party service providers that are only needed on local/testing environments
     */
    if ($this->app->environment() != 'production') {
        /**
         * Loader for registering facades.
         */
        $loader = \Illuminate\Foundation\AliasLoader::getInstance();

        /*
         * Load third party local providers
         */
        $this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);

        /*
         * Load third party local aliases
         */
        $loader->alias('Debugbar', \Barryvdh\Debugbar\Facade::class);
    }
}

and under composer.json in the extra:并在额外的 composer.json 下:

"extra": {
    "laravel": {
        "dont-discover": [
            "barryvdh/laravel-debugbar"
        ]
    }
},

Then you are good to go and enable and disable via .env, if it's different of production it will be enabled (local, testing, etc..) if it's on production it will be automatically disabled.然后你可以通过 .env 启用和禁用,如果它与生产不同,它将被启用(本地、测试等),如果它在生产中,它将被自动禁用。

Hope it helps, good luck!希望能帮到你,祝你好运!

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

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