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

Sinnbeck's avatar
Level 102

Call http controller

How do I call a controller from an artisan command?

0 likes
3 replies
LaryAI's avatar
Level 58

You can call a controller from an artisan command by using the Artisan::call() method. This method takes two parameters: the name of the controller and an array of parameters.

For example, if you wanted to call the FooController controller with the bar method and pass in the $id parameter, you could do the following:

Artisan::call('FooController@bar', ['id' => $id]);
Sinnbeck's avatar
Level 102

Just a quick test of the new ai. Ignore :)

frankielee's avatar

@Sinnbeck Time to guide oxbir "How to use Lary correctly", that might save you time haha

2 likes

Please or to participate in this conversation.