Creating a custom artisan command
Laravel's artisan command-line tool makes many tasks easy to accomplish. If we want to make our own tasks and use artisan to run them, the process is quite simple. In this recipe, we'll see how to make an artisan task that automatically creates an HTML5 skeleton in our views
directory.
Getting ready
For this recipe, we'll need a standard Laravel installation.
How to do it...
To complete this recipe, follow these steps:
In the command line, run the
artisan
command to create our needed files:php artisan command:make SkeletonCommand
In the
app/commands
directory, open theSkeletonCommand.php
file and update the code as follows:<?php use Illuminate\Console\Command; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use Illuminate\Filesystem\Filesystem as File; class SkeletonCommand extends Command { /** * The console command name. * * @var string */ protected $name = 'skeleton:make'; /** ...