How to create a RESTful Resource Controller in Laravel 5.2, using Artisan command (PHP)
Try getting help on the command
php artisan help make:controller
If you see a --resource
flag in the help options you are probably on 5.2 or newer and can add that flag to the command to get a resource controller.
php artisan make:controller --resource SomeResourceController
For Laravel 5.0 and 5.1 the make:controller
command would make a resource controller by default and the --plain
option would make a plain controller.
Laravel 5.2 - Restful Resource Controllers - Default plain
Laravel 5.1 - Restful Resource Controllers - Default resource
Laravel 5.0 - Restful Resource Controllers - Default resource
Summary: from Laravel 5.2 onward the make:controller
artisan command will create a plain controller by default.
For Laravel 5.2
php artisan make:controller NameofController --resource
// It will create the controller with all methods.
If Laravel < 5.2
php artisan make:controller NameofController
// It will create the controller with all methods.
and
php artisan make:controller NameofController --plain
// It will create the controller without any method.
For default controller which have all methods you want. php artisan make:controller LessonsController
If you want plain controller with no method php artisan make:controller --plain LessonsController