php 如何安全地移除 Laravel Debugbar

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48220709/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:38:05  来源:igfitidea点击:

How to safely remove Laravel Debugbar

phplaravellaravel-5

提问by Abdulla Nilam

I have a Laravel application that was not developed by me. There is some weird bar at the bottom of each page, it is some type of Laravel debugger tool.

我有一个不是我开发的 Laravel 应用程序。每个页面底部都有一些奇怪的栏,它是某种 Laravel 调试器工具。

enter image description here

在此处输入图片说明

I believe it is stored in storage/debugger. Is there a safe way I can go about checking to see if this is actually it and if so can I delete this type of tool without it affecting the application? Does anybody know what this thing is if so any advice on how to remove this safely would be greatly appreciated

我相信它存储在存储/调试器中。有没有一种安全的方法可以检查这是否真的是这样,如果是这样,我可以删除这种类型的工具而不影响应用程序吗?有没有人知道这是什么东西,如果有任何关于如何安全删除它的建议将不胜感激

回答by ArnSoos

Best option:

最佳选择:

Add DEBUGBAR_ENABLED=falseto your .env

添加DEBUGBAR_ENABLED=false到您的.env

This has some advantages over Abdulla Nilam's answer:

这比 Abdulla Nilam 的回答有一些优势:

  • Debugbar is totally disabled

  • You can keep APP_DEBUG=true, hence still keep error details for local development

  • It is not tracked by git

  • 调试栏完全禁用

  • 您可以保留APP_DEBUG=true,因此仍然保留本地开发的错误详细信息

  • 它不被 git 跟踪

回答by Abdulla Nilam

Navigate to .envand set

导航到.env并设置

APP_DEBUG=false

Errors & Logging Laravel Doc's

Laravel 文档的错误和日志记录

回答by Yves

Remove Laravel Debugbar

删除 Laravel 调试栏

- If you want to totally remove the package, then do these steps:

- 如果您想完全删除包裹,请执行以下步骤:

  1. $ composer remove vendor/barryvdh/laravel-debugbar
  2. $ composer update
  1. $ composer remove vendor/barryvdh/laravel-debugbar
  2. $ composer update


Disable Laravel Debugbar

禁用 Laravel 调试栏


Option 1:Via Env File


选项 1:通过环境文件

- If you want disable the package, without it getting tracked by Git:

- 如果您想禁用该包,而不会被 Git 跟踪:

  1. Navigate to your .envfile
  2. And put DEBUGBAR_ENABLED = FALSE
  1. 导航到您的.env文件
  2. 并放 DEBUGBAR_ENABLED = FALSE


Option 2:Via AppServiceProvider


选项 2:通过 AppServiceProvider

- From @Ohgodwhy's answer

- 来自@Ohgodwhy回答

- FYI: This will be tracked by Git. - @Salam

- 仅供参考:这将由 Git 跟踪。- @萨拉姆

  1. Navigate to app/Providers/AppServiceProvider.php
  2. Put this code \Debugbar::disable();

    class AppServiceProvider extends ServiceProvider
    {
        public function boot()
        {
            \Debugbar::disable();
        }
    }
    
  1. 导航 app/Providers/AppServiceProvider.php
  2. 把这个代码 \Debugbar::disable();

    class AppServiceProvider extends ServiceProvider
    {
        public function boot()
        {
            \Debugbar::disable();
        }
    }
    

回答by Googlian

Enabling/Disabling on run time.

在运行时启用/禁用。

You can enable or disable the debugbar during run time.

您可以在运行时启用或禁用调试栏。

Add this into your .envfile:

将此添加到您的.env文件中:

DEBUGBAR_ENABLED = FALSE

In runtime:

在运行时:

\Debugbar::enable();
\Debugbar::disable();

Or remove everything

或删除所有内容

composer remove barryvdh/laravel-debugbar

composer remove barryvdh/laravel-debugbar

回答by Ohgodwhy

You can execute composer remove barryvdh/laravel-debugbarto permanently remove it.

您可以执行composer remove barryvdh/laravel-debugbar以永久删除它。

Note you can also just disable the debug bar if you don't want it:

请注意,如果您不想要它,您也可以禁用调试栏:

Just put \Debugbar::disable();in your AppServiceProvider.

只需放入\Debugbar::disable();您的AppServiceProvider.

回答by Florin

I am using this way:

我正在使用这种方式:

In config/debugbar.php

在 config/debugbar.php

'inject'          => false, // this remove Inject Debugbar in Response

In this way I am keeping .php error enable.

通过这种方式,我保持 .php 错误启用。

Another way is to disable completely.

另一种方法是完全禁用。

 'enabled'         => false, 

To enable just debug-bar and disable it for session and Ajax request

仅启用调试栏并为会话和 Ajax 请求禁用它

'enabled'         => true, 

....

....

'storage'         => [
        'enabled'    => false, // DebugBar stores data for session/ajax requests.

or

或者

 'capture_ajax'    => false,

回答by Adam Kozlowski

I removed barryvdh/laravel-debugbarfrom my composer.json. When I wanted to do composer installor composer updateor even php artisan config:cacheI got error

barryvdh/laravel-debugbar从我的composer.json. 当我想要做composer install或者composer update甚至是php artisan config:cache我的错误

[Symfony\Component\Debug\Exception\FatalThrowableError]  
Class 'Barryvdh\Debugbar\ServiceProvider' not found 

If fact the solution was removing boostrap/cache/config.php, because barryvdh/laravel-debugbarwas cached (php artisan config:cachecould not remove it)

如果解决方案正在删除boostrap/cache/config.php,因为barryvdh/laravel-debugbar已缓存(php artisan config:cache无法删除)

Good luck!

祝你好运!

回答by bastiotutuama

It needs to be also removed in the providers: app/config/app.php

它也需要在提供者中删除: app/config/app.php

After:

后:

  1. composer remove vendor/barryvdh/laravel-debugbar
  2. composer update
  1. composer remove vendor/barryvdh/laravel-debugbar
  2. composer update

remove the line:

删除该行:

Barryvdh\Debugbar\ServiceProviderin app/config/app.php.

Barryvdh\Debugbar\ServiceProviderapp/config/app.php 中

Also these folders can be deleted:

也可以删除这些文件夹:

  • app/config/packages/barryvdh/laravel-debugbar/config.php
  • another Debugbar-related file somewhere under app/storage/...
  • app/config/packages/barryvdh/laravel-debugbar/config.php
  • 下某处的另一个与调试栏相关的文件 app/storage/...