I can't turn off debug bar in Laravel on production
Asked Answered
P

5

12

I have set

'enabled' = false

in both package and in 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

@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

Petrochemical answered 20/10, 2017 at 12:7 Comment(0)
K
2

Solution for 5.5 and above

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.

Solution for 5.4 and below

Put this code to the 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.

After doing this, Laravel Debugbar will only be loaded in a local environment.

Kibbutznik answered 20/10, 2017 at 12:9 Comment(3)
I did it, but that didn't help. What does it do to turn OFF the debugbar?Asafetida
@ZbigniewKisły if you're on 5.5, look at updated answer. Also, try to clear view cache with php artisan view:clearKibbutznik
barryvdh/laravel-debugbar v3.0.0 supports Laravel 5.5 + Auto Discovery, but it is not helping to disable it on EC2Optimize
M
12

Go To .env And Set

DEBUGBAR_ENABLED=false

OR

APP_DEBUG=false

Marquez answered 31/3, 2021 at 14:36 Comment(1)
best answer simple env changeAchene
O
11

It is not a matter of debugbar, it is general problem with .env. You can change your APP_NAME to see that it is not changing anything.

To apply your new config changes including .env changes you need to run artisan command in your project folder:

php artisan config:cache
Optimize answered 17/5, 2018 at 1:30 Comment(0)
F
6

Did u try changing it in the .env file?

Look for the value APP_DEBUG in the .env file and set it false.

Out of the box, .env has it set to true.

Foredeck answered 20/10, 2017 at 12:25 Comment(2)
it works on my vagrant homestead, but it is not working on ec2Optimize
Its working on ec2, try clearing the config with php artisan config:clearFootton
K
2

Solution for 5.5 and above

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.

Solution for 5.4 and below

Put this code to the 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.

After doing this, Laravel Debugbar will only be loaded in a local environment.

Kibbutznik answered 20/10, 2017 at 12:9 Comment(3)
I did it, but that didn't help. What does it do to turn OFF the debugbar?Asafetida
@ZbigniewKisły if you're on 5.5, look at updated answer. Also, try to clear view cache with php artisan view:clearKibbutznik
barryvdh/laravel-debugbar v3.0.0 supports Laravel 5.5 + Auto Discovery, but it is not helping to disable it on EC2Optimize
M
0

if you are on 5.4 you can do under AppServiceProvider as follows:

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:

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:

"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.

Hope it helps, good luck!

Massasauga answered 26/1, 2018 at 23:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.