10-Apr-2023
.
Admin
Hi Guys,
In this tutorial, I will let you know laravel 6 create controller using command. we will learn How to Create Controller in Laravel 6 using Command. i will give you more examples of artisan command to create controller in laravel 6.
You can see list of examples of artisan command to create controller in laravel 6.
Example 1:
php artisan make:controller PostController
->It will create simple controller class name
->It will also create fille following path.
1.controller:-
app/Http/Controllers/PostController.php
Example 2.
php artisan make:controller PostController --resource
->It will create controller name with file.
->It will also create following methods as resource controller as PostController:
index,create,store,show,edit,update,destroy
->It Will passing the argument as --resource.
->It will also create fille following path.
1.controller:-
app/Http/Controllers/PostController.php
Example 3.
php artisan make:controller PostController --resource --model=Post
->It will create controller name and model with file.
->It will also create following methods as resource controller as PostController:
index,create,store,show,edit,update,destroy
->It Will passing the argument as --resource and --model.
->It will also create fille following path.
1.controller:-
app/Http/Controllers/PostController.php
2.model:-
app/Post.php
Example 4.
php artisan make:controller PostController --api
->It will create api controller name with file.
->It will also create following methods as resource controller as PostController:
index,create,store,show,edit,update,destroy
->It Will passing the argument as --api.
->It will also create fille following path.
1.controller:-
app/Http/Controllers/PostController.php
Example 5.
php artisan make:controller PostController --invokable
->It will create api controller name with file.
->It will also create following methods as resource controller as PostController:
__invoke
->It Will passing the argument as --invokable.
->It will also create fille following path.
1.controller:-
app/Http/Controllers/PostController.php
Example 6.
php artisan make:controller PostController --parent=Post
->It will create controller name and model with file.
->It will also create following methods as resource controller as PostController:
index,create,store,show,edit,update,destroy
->It Will passing the argument as --parent.
->It will also create fille following path.
1.controller:-
app/Http/Controllers/PostController.php
2.model:-
app/Post.php
->It will Call method in all require parameter
It will help you......
#Laravel
#Laravel 6