Sorry, this video is only available to Pro accounts.

Upgrade your account to get access to all content.

Creating Artisan Commands in Laravel 5

Created on June 5th, 2016

In this video we'll show you how to create your own Laravel 5 commands using php artisan. This video will teach you the following 6 topics:

  1. Creating your command
  2. Adding arguments
  3. Adding options
  4. Prompting for input
  5. Writing output
  6. Adding a progress bar

Creating your command is very easy, you can simply use an artisan command to create a new command:

php artisan make:console SayHello

And you will have a new file created inside of your app/Console/Commands folder called SayHello.php.

Then to accept arguments in your command you can include it in the signature of your file. In order to add options you will also include this in the signature variable as discussed in the video. Lastly we teach you how to ask for user input, write out text to the console, and we'll also show you how to display a progress bar in the console in case you are running a really long task.

Comments (0)