benjaminhu/laravel-app-debug-dynamic

Enabling Laravel APP_DEBUG dynamically in production environment

1.0.0 2022-07-03 11:34 UTC

This package is auto-updated.

Last update: 2024-10-30 01:54:02 UTC


README

Installation

You can install the package via composer:

$ composer require benjaminhu/laravel-app-debug-dynamic

Usage

Simply register the newly created class in your (top of) middleware stack.

// app/Http/Kernel.php
class Kernel extends HttpKernel
{
    protected $middleware = [
        \Benjaminhu\LaravelAppDebugDynamic\AppDebugDynamicMiddleware::class,
        // ...
    ];
    // ...
}

Publish config:

$ php artisan vendor:publish --provider="Benjaminhu\LaravelAppDebugDynamic\AppDebugDynamicServiceProvider"

Setup .env (remember: in production mode alway set: APP_DEBUG=false!):

# ...
APP_DEBUG=false
APP_DEBUG_DYNAMIC_COOKIE_NAME=<CHOOSE COOKIE NAME>
APP_DEBUG_DYNAMIC_COOKIE_SECRET=<CHOOSE COOKIE SECRET>
# optional
# APP_DEBUG_DYNAMIC_ALLOWED_IPS=<LIST, OF, ALLOWED, IP, ADDRESSES>
# ...

Testing

$ composer test