Chapter 7. Artisan and Tinker
From installation onward, modern PHP frameworks expect many interactions to take place on the command line. Laravel provides three primary tools for command-line interaction: Artisan, a suite of built-in command-line actions with the ability to add more; Tinker, a REPL or interactive shell for your application; and the installer, which we’ve already covered in Chapter 2.
An Introduction to Artisan
If you’ve been reading through this book chapter by chapter, you’ve already learned how to use Artisan commands. They look something like this:
php artisan make:controller PostsController
If you look in the root folder of your application, you’ll see that artisan is actually just a PHP file. That’s why you’re starting your call with
php artisan; you’re passing that file into PHP to be parsed. Everything after that is just passed into Artisan as arguments.
Symfony Console syntax
Artisan is actually a layer on top of the Symfony Console component, so if you’re familiar with writing Symfony Console commands you should be right at home.
Since the list of Artisan commands for an application can be changed by a package or by the specific code of the application, it’s worth checking every new application you encounter to see what commands are available.
To get a list of all available Artisan commands, you can run
php artisan list from the project root (although if you just run
php artisan with no parameters, it will do the same thing).