tpetry/laravel-mysql-explain

[Bug]: Methods dumpVisualExplain and ddVisualExplain not working

Closed this issue · 5 comments

Fayne commented

What happened?

I'm trying dumpVisualExplain() and ddVisualExplain() methods in my local environment. But neither of them is working in PHP 8.3 and Laravel 11.21.0 version.

image

And when i used ddVisualExplain() method in my web.php file, it shown an error Symfony\Component\HttpFoundation\Response::setContent(): Argument #1 ($content) must be of type ?string, Illuminate\Database\Eloquent\Builder given, called in /var/www/vendor/laravel/framework/src/Illuminate/Http/Response.php on line 73

How to reproduce the bug

Route::get('/dump', function () {
    User::where('name', 'like', '%Taylor%')->dumpVisualExplain()->get();

    return 'Hello World!';
});


Route::get('/dd', function () {
    User::where('name', 'like', '%Taylor%')->ddVisualExplain();

    return 'Hello World!';
});
image image image

Package Version

1.3.1

PHP Version

8.3

Laravel Version

10.21

Which operating systems does with happen with?

Linux

Notes

No response

tpetry commented

There is no dump visibile in your dump example. Thats weird!

And the error message for the dd example seems to not match the code. Can you share the full strack trace?

Fayne commented

Hi @tpetry

Thank you for your support. Here is my stack trace:

[2024-09-03 09:54:01] local.ERROR: syntax error, unexpected token "return" {"exception":"[object] (ParseError(code: 0): syntax error, unexpected token \"return\" at /var/www/routes/web.php:19)
[stacktrace]
#0 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php(513): Illuminate\\Routing\\RouteFileRegistrar->register()
#1 /var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php(467): Illuminate\\Routing\\Router->loadRoutes()
#2 /var/www/vendor/laravel/framework/src/Illuminate/Routing/RouteRegistrar.php(194): Illuminate\\Routing\\Router->group()
#3 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Configuration/ApplicationBuilder.php(221): Illuminate\\Routing\\RouteRegistrar->group()
#4 /var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Foundation\\Configuration\\ApplicationBuilder->Illuminate\\Foundation\\Configuration\\{closure}()
#5 /var/www/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#6 /var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(81): Illuminate\\Container\\Util::unwrapIfClosure()
#7 /var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\\Container\\BoundMethod::callBoundMethod()
#8 /var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php(690): Illuminate\\Container\\BoundMethod::call()
#9 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php(162): Illuminate\\Container\\Container->call()
#10 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/RouteServiceProvider.php(59): Illuminate\\Foundation\\Support\\Providers\\RouteServiceProvider->loadRoutes()
#11 /var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Foundation\\Support\\Providers\\RouteServiceProvider->Illuminate\\Foundation\\Support\\Providers\\{closure}()
#12 /var/www/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#13 /var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(81): Illuminate\\Container\\Util::unwrapIfClosure()
#14 /var/www/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\\Container\\BoundMethod::callBoundMethod()
#15 /var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php(690): Illuminate\\Container\\BoundMethod::call()
#16 /var/www/vendor/laravel/framework/src/Illuminate/Support/ServiceProvider.php(130): Illuminate\\Container\\Container->call()
#17 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1122): Illuminate\\Support\\ServiceProvider->callBootedCallbacks()
#18 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1100): Illuminate\\Foundation\\Application->bootProvider()
#19 [internal function]: Illuminate\\Foundation\\Application->Illuminate\\Foundation\\{closure}()
#20 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1099): array_walk()
#21 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\\Foundation\\Application->boot()
#22 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(316): Illuminate\\Foundation\\Bootstrap\\BootProviders->bootstrap()
#23 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(473): Illuminate\\Foundation\\Application->bootstrapWith()
#24 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(195): Illuminate\\Foundation\\Console\\Kernel->bootstrap()
#25 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1203): Illuminate\\Foundation\\Console\\Kernel->handle()
#26 /var/www/artisan(13): Illuminate\\Foundation\\Application->handleCommand()
#27 {main}
"} 
tpetry commented

A syntax error is something completely else. Your application has invalid PHP in the routes/web.php.

Fayne commented

Hi @tpetry

As you can see, there is not too much codes in my web.php file. I don't think there is any syntax error in web.php file.

tpetry commented

The last stack trace clearly indicates a problem with your code. And the initial issue doesn't match the code too. This is not a problem of this package.