Skip to main content
Tutorial Free

Create Controller and Model in one Artisan Command

May 29, 2017
1 min read

Tutorial last revisioned on August 11, 2022 with Laravel 9

Laravel is full of little tricks, and quick ways to generate code with Artisan. One of the recent ones I've found is when you're creating a CRUD record and need to create Model + Controller. You don't need two separate commands for that. How I was doing it until now:
php artisan make:model Customer
php artisan make:controller CustomersController --resource
Apparently, there's a quicker way:
php artisan make:controller CustomersController --model=Customer
And that's it. Laravel will actually ask you if you want to generate the model: laravel controller model artisan But that's not everything! You can create more. All available options you can check by writing
php artisan make:controller --help
That's it, quick tip to perform quick operation!

Enjoyed This Tutorial?

Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.

Recent Courses

Laravel Modules and DDD

16 lessons
1 h 59 min

NativePHP: Build Mobile App with Laravel

11 lessons
2 h 2 min read

Laravel HTTP Client and 3rd-Party APIs

7 lessons
50 min

Comments & Discussion

No comments yet…

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.