What the F*ck Is With All the Artisan Commands: Quickies
As I’ve been organizing the flow of this series there’s a random set of commands that don’t really have a good home. I thought I would cover them now so they’re out of the way.
list
The list
command displays all of the registered commands that artisan has available.
Please note: I have snipped out a huge section in the middle of this for berevity. The full list can be found at http://www.thisprogrammingthing.com/what-the-f-ck-is-with-all-the-artisan-commands-intro/
Why It Exists
The list
command exists to give a full list of the available artisan commands.
When Should You Use It
When you can’t quite remember the name of a command, list
will let you read them all so you can remember.
help
The help command shows help information for a specific command.
Why It Exists
The help
command exists to give a full list of the available options for a given command.
When Should You Use It
When you need to see the available options for a specific command.
inspire
The inspire
command lists an inspirational quote.
Why It Exists
The command will help you feel better.
When Should You Use It
Any time you need a pick me up.
env
The env
command displays the current application environment.
Why It Exists
No idea.
When Should You Use It
No idea again. You could always open the “.env” so I fail to see the benefit of this command.
key:generate
When you initially create your Laravel application the “.env” file starts out like the following:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
When you attempt to do anything you’ll receive the following error message:
No application encryption key has been specified.
To fix this you’ll need to run the key:generate
command.
Now if you check your “.env” file the APP_KEY will have a value and you won’t receive the “No application encryption key has been specified.” exception.
Why It Exists
The APP_KEY environmental variable is used by the encrypt()
and decrypt()
functions as the input to generate encryption keys.
Here’s a quick example of how easy it is to encrypt and decrypt your data:
Output:
eyJpdiI6IllLOFNYcmE5R3lCbjFqVEpvVzFKZkE9PSIsInZhbHVlIjoiSlZIM2RvYlQ0c25Eb21UMEx0Wk1mTjdJdkNMZDhHVjVsN3Y2T0diY2FyRT0iLCJtYWMiOiIzNjQwMWE4MzgwNWNlMWY1NDRmYzg4YjdmOTFmMDdlMDNkZTUxYmVjMzgxOTExZDQ4Njk4NTYwNGUwMTdiZTAwIn0=
test string
When Should You Use It
When you initially create your application and then never again because running it a second time creates a new key and prevents you from decrypting your data.
up/down
The up
and down
commands exist in order to place your application into maintenance mode (down
) and bring it back out of maintenance mode (up
).
Here’s a quick example.
Now if we try to access our application we get a “service unavailable” message.
Why It Exists
To place your application into maintenance mode and bring it back.
When Should You Use It
When you need to perform a large change to your database or server and don’t want people trying to make changes that might be lost.
Hopefully this has been as helpful to you as it has to me and check back soon for more artisan commands.
Scott Keck-Warren
Scott is the Director of Technology at WeCare Connect where he strives to provide solutions for his customers needs. He's the father of two and can be found most weekends working on projects around the house with his loving partner.
Top Posts
- Working With Soft Deletes in Laravel (By Example)
- Fixing CMake was unable to find a build program corresponding to "Unix Makefiles"
- Upgrading to Laravel 8.x
- Get The Count of the Number of Users in an AD Group
- Multiple Vagrant VMs in One Vagrantfile
- Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error
- Changing the Directory Vagrant Stores the VMs In
- Accepting Android SDK Licenses From The OSX Command Line
- Fixing the 'Target class [config] does not exist' Error
- Using Rectangle to Manage MacOS Windows