bobinwood's avatar

Debugbar in a production environment

I am on a hosted server and I try to optimize the cache on the production server by launching php artisan config:cache. As I cannot run phpcli on the server, I wrote a temporary function in a controller to start this artisan command. I run composer install --optimize-autoloader --no-dev on my local dev server in order to remove any reference to debugbar in the vendor/composer directory and I uploaded these files on the hosted server. When I run the artisan command "config:cache" I got the following error in laravel.log production.ERROR: Class Barryvdh\Debugbar\Controllers\OpenHandlerController does not exist. They should not be any reference to Debugbar in the code ! . here is the code for launching the command.

public function artisanCommand(Request $request) {
        $key=$request->key;

        try {
            \Artisan::call($key);
            dd(\Artisan::output());
        } catch (Exception $e) {
            Response::make($e->getMessage(), 500);
        }
    }
0 likes
7 replies
Vilfago's avatar

Do you still have reference to debugbar in the .env file ?

Not see how it can have an impact, but I don't have a better idea so far.

Vilfago's avatar

or hard coded in the config/app.php file ?

bobinwood's avatar

No reference in .env and no reference in config.app.php. I checked also all files in the vendor/composer directory. No Debugbar found.

shez1983's avatar

in your composer.json is debug bar in require[] array or the other require-dev[] ?

rodrigo.pedra's avatar
Level 56

I am guessing, but is seems that you upload your project files manually (or via FTP) to your server.

If so, before uploading run these commands locally:

php artisan route:clear
php artisan config:clear

From the error I am guessing you are uploading the cached routes file, so the router tries to access a Controller that no longer exists.

Locally the error might not happen because if the .env file is configured to local/debug it regenerates the route cache each time.

bobinwood's avatar

It works finally. Here is what I have done

php artisan route:clear
php artisan config:clear
composer install --optimize-autoloader --no-dev
php artisan route:cache

Then I uploaded vendor/composer and later boostrap/cache to the production server and now it works.

Thanks to all for the help

Please or to participate in this conversation.