Value In Brief – by Abanoub Hanna
All You Need To Know Explained In Brief

Laravel Commands Cheatsheet

Laravel PHP

laravel new project-name

create a new folder named “project-name” in the current directory. Then create all necessary Laravel project files inside it.

composer require vendor/package

update composer.json with the necessary details of the package you are choosing to install, then install the package in your project.

composer update

update the installed packages.

composer dump-autoload

updates your vendor/composer/autoload_classmap.php file. You have to run this command if you have a new class in your project that has not yet been loaded.

php artisan list

list all the artisan commands

php artisan --help or php artisan -h

display some basic help.That shows all/some the available flags for php artisan

php artisan key:generate

generates a new key and adds it to your .env file. A key is automatically generated and added to .env file when you use laravel new projectName. But it is useful when you clone an existing project. This app key is mainly ised for encrypting cookies.

php artisan --version or php artisan -V

displays your current version of Laravel.

php artisan down

puts your application into maintenance mode. Visitors will see the maintenance message.

php artisan up

brings your application (website) back out of maintenance mode.

php artisan env

displays the current environment for your application (website) like this Current application environment:local

php artisan route:list

lists all the routes registered in your application, under the following headers:

Domain, Method, URI, Name, Action, Middelware

php artisan serve

runs a local web server and tells you the local url to use to show the website / application. If you want to specify a port and host use a command like this php artisan serve --host= --port=80.

php artisan make:auth

creates all that is necessary for authentication in your application. Make sure you run php artisan migrate after this command. After that, you can navigate to /register or /login on your project to create and log in an account.

php artisan make:model ModelName -mcr

creates a model class and file in your project. You can use some, none or all of the -mcr flags when creating a new model.

-m or --migrationcreates a new database migration file for the model
-c or --controllercreates a new controller file for the model
-r or --resourcesindicates if the generates controller should be a resource controller

If you want to see all options, run this command php artisan make:model -h.

php artisan make:controller ControllerName

creates a controller file in your project. You can specify a controller for which model via this flag --model=ModelName so the command will be php artisan make:controller UserController --model=User if the User is the name of a model.

php artisan make:migration --table='table' 'description_of_migration'

creates a database migration file that you can edit to add necessary table properties.

php artisan migrate

runs any pending database migrations.

php artisan migrate:rollback

Rolls back the latest database migration (ensuring you have the necessary commands in your down() function of the migration).

if you want to roll back the last 5 migrations, just use this command php artisan migrate:rollback --step=5.

php artisan migrate:reset

rolls back all migrations.

php artisan vendor:publish

displays a list of vendor packages installed in your project, giving you the option to specify which you would like to copy the configuration or view files toyour own project’s folders for additional configuration or customization.

php artisan route:cache

speed up your application for production caching all your application’s routes.

php artisan route:clear

clear the cached version of your routes — use this on local deployments if you have cached routes. Re-run the cache command above on production to clear and re-cache routes.

php artisan clear-compiled

remove the compiled class file.

php artisan optimize

cache the framework bootstrap files.

php artisan test

run the application tests.

php artisan tinker

interact with your application.

php artisan auth:clear-resets

flush expired password reset tokens


php artisan cache:clear

flush the application cache.

php artisan cache:forget

remove an item from the cache.

php artisan cache:table

create a migration for the cahce database table.


php artisan config:cache

create a cache file for faster configuration loading. That speeds up your application for production by combining all your config options into a single file that loads quickly.

php artisan config:clear

removes / clears your cached config (configuration cache file)—use this on local deployments if you have cached config. Re-run the cache comman above on production to clear and re-cache config.

database (db)

php artisan db:seed

seed the database with records.

php artisan db:wipe

delete / drop all tables, views, and types.


php artisan event:cache

discover and cache the application’s events and listeners.

php artisan event:clear

clear all cached events and listeners.

php artisan event:generate

generate the missing events and listeners based on registration.

php artisan event:list

list the application’s events and listeners.

make commands

php artisan commandmeaning
make:channelCreate a new channel class
make:commandCreate a new Artisan command
make:componentCreate a new view component class
make:controllerCreate a new controller class
make:eventCreate a new event class
make:exceptionCreate a new custom exception class
make:factoryCreate a new model factory
make:jobCreate a new job class
make:listenerCreate a new event listener class
make:mailCreate a new email class
make:middlewareCreate a new middleware class
make:migrationCreate a new migration file
make:modelCreate a new Eloquent model class
make:notificationCreate a new notification class
make:observerCreate a new observer class
make:policyCreate a new policy class
make:providerCreate a new service provider class
make:requestCreate a new form request class
make:resourceCreate a new resource
make:ruleCreate a new validation rule
make:seederCreate a new seeder class
make:testCreate a new test class

migrate commands

php artisan commandmeaning
migrate:freshDrop all tables and re-run all migrations
migrate:installCreate the migration repository
migrate:refreshReset and re-run all migrations
migrate:resetRollback all database migrations
migrate:rollbackRollback the last database migration
migrate:statusShow the status of each migration

php artisan notifications:table

creates a migration for the notifications table.

php artisan optimize:clear

Remove the cached bootstrap files

php artisan package:discover

Rebuild the cached package manifest

queue commands

php artisan commandmeaning
queue:failedList all of the failed queue jobs
queue:failed-tableCreate a migration for the failed queue jobs database table
queue:flushFlush all of the failed queue jobs
queue:forgetDelete a failed queue job
queue:listenListen to a given queue
queue:restartRestart queue worker daemons after their current job
queue:retryRetry a failed queue job
queue:tableCreate a migration for the queue jobs database table
queue:workStart processing jobs on the queue as a daemon

route commands

php artisan commandmeaning
route:cacheCreate a route cache file for faster route registration
route:clearRemove the route cache file
route:listList all registered routes

php artisan schedule:run

Run the scheduled commands.

php artisan session:table

Create a migration for the session database table.

Create the symbolic links configured for the application.

php artisan stub:publish

Publish all stubs that are available for customization.

view commands

php artisan view:cacheCompile all of the application’s Blade templates
php artisan view:clearClear all compiled view files

Final thoughts & tips

I personally add an alias for php artisan because I have to write it again and again. I just add this line to the end of my .zshrc or .bashrc on my Linux or Mac.

alias pa="php artisan"

So, I can write pa serve which means php artisan serve.

If you have any recommendations or tips or questions for me, tweet to me on twitter. And if you found this post useful, recommend it to a friend or share it with him/her.

« Does a Zip File Reduce File Size ? rsnapshot HOWTOs Docs »