Creating a Single Action Controller

  • Laravel

To create a single action controller, use the following Artisan command:

1php artisan make:controller ShowPostController --invokable

This command creates a controller with only one action, named __invoke. For more information about the __invoke magic method, refer to the Laravel documentation.