Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MarBel's avatar

Run Spark controller in terminal

I'm trying to run a controller function from tinker using this code:

php artisan tinker
$controller = app()->make('App\Http\Controllers\MyController');
app()->call([$controller, 'myMethodName'], []);

The controller is in \spark\src\Http\Controllers\..., not App. When I try the above code on a controller in the App dir, it works, but when I try to do it with a controller in the spark dir, I get this:

ReflectionException with message 'Class spark/src/Http/Controllers/... does not exist'

(... added by me)

0 likes
3 replies
martinbean's avatar

@MarBel Why are you trying to run a controller—which is expected to run in a HTTP context—via the command line?

MarBel's avatar

@martinbean when I try to test this controller in the browser its giving me a 404, even though everything is seemingly where it should be. Just looking for another way to investigate.

martinbean's avatar

@MarBel You could try Laravel Debugbar. That will show you what exceptions are being thrown in a HTTP request, i.e. if you’re looking up a model that doesn’t exist.

Please or to participate in this conversation.