Skip to content

Controller Generator ‚Äč

The Controller Generator Command, will create a new Controller for the provided Module with a basic boilerplate code. If you want to create a new ProfileController file, for the Customer Module, you can run the following command:

bash
php artisan modular:make-controller Customer Profile

Or if you are using Laravel Sail, run:

bash
sail artisan modular:make-controller Customer Profile

And a new ProfileController.php file will be created at modules/Customer/Http/Controllers/ProfileController.php.

The Modular Controller Generator will add the correct namespace and common imports following a suggested pattern. It will also provide Inertia Responses, expected by the Frontend Vue Pages/Components, to keep the flow with minimum code for common operations.

You will need to generate the corresponding files to make the Controller work properly, like the Profile Model and HTTP Request Validator for the Controller created. You are free to adapt the generated code to the needs of your implementation.