In Laravel 7.x, I used to debugging interactively by putting eval(\Psy\sh()); in the code.
After upgrading to Laravel 8. it seems not working anymore.
Is there any other way to do interactive debugging in Laravel 8?
In Laravel 7.x, I used to debugging interactively by putting eval(\Psy\sh()); in the code.
After upgrading to Laravel 8. it seems not working anymore.
Is there any other way to do interactive debugging in Laravel 8?
I haven't found a proper solution. So, the issue is here. The new way of artisan serve way is to create a process and when you try to use Psy it creates a new process.
(standard input):198: 434 ?? 0:11.07 /usr/local/opt/php/sbin/php-fpm --nodaemonize
(standard input):406:80139 ?? 0:00.00 /usr/local/opt/php/sbin/php-fpm --nodaemonize
(standard input):407:80214 ?? 0:00.00 /usr/local/opt/php/sbin/php-fpm --nodaemonize
(standard input):419:79506 ttys000 0:13.80 nvim app/Http/Controllers/UsersController.php
(standard input):422:80288 ttys001 0:00.19 php artisan serve
(standard input):423:80292 ttys001 0:02.66 /usr/local/Cellar/php/8.0.1/bin/php -S 127.0.0.1:8000 /server.php
(standard input):424:80387 ttys001 0:00.00 (php)
(standard input):425:80436 ttys001 0:00.00 (php)
The last two PID are two of the Psy I tried to run.
You can see I forked symfony and I changed the value to true.
That will allow you again to work as before. To get out of the process, CTRL+D.
If the version is lower, you can check out this one
However, be aware that this might be an issue in read-only environments.
I also faced the same problem when running Laravel with php artisan serve. In the same terminal where I run the command, the PsySH breakpoint uses eval(\Psy\sh()); always automatically closed.
The only solution I can find at this point after some trial and error is to run the request via the Laravel Tinker REPL with php artisan tinker. So in the CLI, you can make a request to the route you created with the following code:
// The following '/foo' is the endpoint of the route you created
$request = \Illuminate\Http\Request::create('/foo', 'get');
app()->make(\Illuminate\Contracts\Http\Kernel::class)->handle($request);
Then you can do interactive debugging using PsySH as usual.