0

New to Lavarel.

I am trying to debug a controller's method in Laravel, to do so I'm using Tinker (which is based on Psysh).

I added both of these versions to the breakpoint inside the method signup of my MySuperController:

extract(\Psy\Shell::debug(get_defined_vars()));
eval(\Psy\sh());

I've run php artisan tinker and done the following in the console:

$controller = app()->make('\App\Http\Controllers\Api\V1\MySuperController');
app()->call([$controller, 'signup'], ["param"=>"value"]);

When executing that, Tinker responds with: Illuminate\Validation\ValidationException with message 'The given data was invalid.'

But I never see the code stop on the breakpoint. Did I assume wrongly that I could debug step by step with Tinker?

Chayemor
  • 3,577
  • 4
  • 31
  • 54
  • 1
    are you using a form request to validate? if so they are resolved and validated before your controller method is called – lagbox Feb 11 '21 at 19:28
  • hey @lagbox , there doesn't seem to be one. There's a route, it points directly to a controller and the method. I'll keep on searching though. I don't see any $request->validated() called yet. – Chayemor Feb 12 '21 at 09:52
  • hey @lagbox, you were absolutely right, can you post it as an answer? the method was using a custom request class, which extended from an abstract one, which extended from api/application/vendor/laravel/framework/src/Illuminate/Foundation/Http/FormRequest.php . I added the eval() within that class and it finally got to the breakpoint. Awesome! – Chayemor Feb 12 '21 at 10:31

1 Answers1

1

This answer was based off of user @lagbox's comment. I asked them to make it an answer so I could choose it, but it's been 4 months, so I'm creating it myself so others can quickly see the question has been answered:

User @lagbox mentioned in a comment:

are you using a form request to validate? if so they are resolved and validated before your controller method is called

The comment was spot on. Tmethod was using a custom request class, which extended from api/application/vendor/laravel/framework/src/Illuminate/Foundation/Http/FormRequest.php . I added the eval() within that class and it finally got to the breakpoint.

Chayemor
  • 3,577
  • 4
  • 31
  • 54