Laravel Create Custom Artisan Command with Example
https://www.itsolutionstuff.com/post/laravel-5-create-custom-artisan-command-with-exampleexample.html
Last updated
https://www.itsolutionstuff.com/post/laravel-5-create-custom-artisan-command-with-exampleexample.html
Last updated
By Hardik Savani May 23, 2016 Category : LaravelPauseUnmuteLoaded: 2.13%FullscreenIt's better if we make our own artisan command for like project setup, create new admin user etc in our laravel application. If we create custom command then we can make project setup like create one admin user, run migration, run seeder and etc. In this post i give you example, how to create console commands in laravel project.
In this example will create custom command for create new admin user. This custom command will ask your name, email and password. In this example we will create command like:
Custom command
This command through we will create new admins. So first fire bellow command and create console class file.
After this command you can find one file AdminCommand class in console directory. so one that file and put bellow code.
app/Console/Commands/AdminCommand.php
Ok, now we need to register this command class in Kernel.php file, so open file and add class this way:
app/Console/Kernel.php
Now we are ready to use or custom command, you fire bellow command and check you can find command in the list this way "admins:create".
Read Also: Laravel - How to create custom error page with example
you can checkkk....