Why Artisan Commands Used In Laravel Framework With Example
Posted By
Bajarangi soft ,
Posted On 10-09-2020
Artisan is the name of the command-line interface included with Laravel. It provides a number of helpful commands for your use while developing your application. It is driven by the powerful Symfony Console component.
Listing All Available Commands
To view a list of all available Artisan commands, you may use the list
command:
Run below command in command prompt after you installed laravel project:
If you run above command you get ouput like following:
Laravel Framework 5.8.35
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
clear-compiled Remove the compiled class file
down Put the application into maintenance mode
dump-server Start the dump server to collect dump information.
env Display the current framework environment
help Displays help for a command
inspire Display an inspiring quote
list Lists commands
migrate Run the database migrations
optimize Cache the framework bootstrap files
preset Swap the front-end scaffolding for the application
serve Serve the application on the PHP development server
tinker Interact with your application
up Bring the application out of maintenance mode
app
app:name Set the application namespace
auth
auth:clear-resets Flush expired password reset tokens
cache
cache:clear Flush the application cache
cache:forget Remove an item from the cache
cache:table Create a migration for the cache database table
config
config:cache Create a cache file for faster configuration loading
config:clear Remove the configuration cache file
datatables
datatables:html Create a new DataTable html class.
datatables:make Create a new DataTable service class.
datatables:scope Create a new DataTable Scope class.
.......
Now You can Run below Artisan commands in Laravel projects
Viewing The Help Screen For A Command
Every command also includes a "help" screen which displays and describes the command's available arguments and options. To view a help screen, simply precede the name of the command with help
:
Run below command in command prompt after you installed laravel project:
Specifying The Configuration Environment
You may specify the configuration environment that should be used while running a command using the --env
switch:
Run below command in command prompt after you installed laravel project:
php artisan migrate --env=local
Displaying Your Current Laravel Version
You may also view the current version of your Laravel installation using the --version
option:
Run below command in command prompt after you installed laravel project: