Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The package overrides the default Laravel's VarDumpers and file context disappears #95

Open
ekateiva opened this issue Nov 21, 2024 · 0 comments

Comments

@ekateiva
Copy link

When this package is installed, it overrides VarDumper handler that comes from Laravel (Illuminate\Foundation\Http\HtmlDumper and Illuminate\Foundation\Console\CliDumper).

To compare, when the package is not installed:
Screenshot 2024-11-21 at 13 04 11

And when it is installed, but the command not running:
Screenshot 2024-11-21 at 13 04 28

The same in CLI.

When the command (php artisan dump-server) is not running, I would like to see the file context by default.


Suggestion:

As a suggestion, maybe the setting could be introduced to enable/disable the package? E.g. config:

...
    'enabled' => env('DUMP_SERVER_ENABLED', true),
...

Then in DumpServerServiceProvider it could be conditionally loaded:

        if ($this->app['config']->get('debug-server.enabled')) {
            VarDumper::setHandler(function ($var) use ($connection) {
                $this->app->makeWith(Dumper::class, ['connection' => $connection])->dump($var);
            });
        }

The command php artisan dump-server could give an error if it is not enabled:

        if (! config('dump-server.enabled')) {
            $this->error('The dump server is not enabled.');

            return;
        }

This would allow users to choose if they want it always enabled, or occasionally and would not override other VarDump registered handlers.

WDYT, I could open a pull request if it's reasonable idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant