2.8.4.2.5. Artisan Utility
The Artisan utility is a console interface for working with the Laravel framework that comes with it and is installed with project creation... This utility simplifies the work with the framework and provides a huge range of possibilities.
Using Artisan
The utility and its commands are launched directly from the framework project directory. To use do the following:
- Change to your project directory by running the command:
cd ~/example.com/www/
Instead
example.com/www
indicate site root directory. - By default in the environment SSH the hosting uses PHP 5.6. According to the requirements of the framework, a version of at least 7.3 is required, so override the paths in the variable
$PATH
by running the command:export PATH=/usr/local/php73/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
- Run the command to check if Artisan is working:
php artisan
- Subsequent command run
artisan
possible only from its catalog. If you need to create a command that will be called without the need to go to the directory, then run the following command:echo "alias command='/usr/local/php73/bin/php ~/example.com/www/artisan'" >> ~/.bashrc && source ~/.bashrc
Modify the above command based on the information you need:
- Instead «command» provide the desired command name to be used. For example, you can specify the name of the project by type
laravel_example
. - Instead «example.com/www» indicate site root directory.
- Test the command by running:
command -V
The standard output of this command will be the version of the installed framework.
Artisan Teams
artisan
.To list the available commands, run the following command:
php artisan list
For all commands, you can get help on how to use them. To do this, use the command help
with the name of the command for which you want to get information:
php artisan help list
If you enter a command incorrectly, similar options will be offered, for example:
You can familiarize yourself with how Artisan commands work in laravel.su documentation1) or in official documentation.
Team | Description |
---|---|
Basic commands | |
clear-compiled | Remove compiled class files |
down | Enable Maintenance Mode / Demo Mode |
env | Displaying the current parameters of the framework environment |
help | Help output by command |
inspire | Inspirational quote conclusion |
list | Getting a list of available commands |
migrate | Starting Database Migration |
optimize | Optimizing include files by creating cache files |
serve | Starting the server (within the framework of shared hosting, the command will not work correctly) |
test | Run application tests |
tinker | Interacting with the application |
up | Disable Maintenance Mode / Demo Mode |