composer create-project laravel/laravel example-appphp artisan servecp .env.example .envcopy .env.example .envphp artisan key:generateCreate a New Controller:
php artisan make:controller PhotoControllerCreate a Single Action Controller:
php artisan make:controller ProvisionServer --invokableCreate a Resource Controller:
php artisan make:controller PhotoController --resourceCreate a Resource Controller with its Own Model:
php artisan make:controller PhotoController --model=Photo --resourceCreate a Resource Controller with its Own Model and Custom Requests:
php artisan make:controller PhotoController --model=Photo --resource --requestsCreate an API Controller:
php artisan make:controller PhotoController --apiYou can get a quick overview of your application's configuration, drivers, and environment via the about Artisan command
php artisan aboutIf you're only interested in a particular section of the application overview output, you may filter for that section using the --only
php artisan about --only=environmentTo explore a specific configuration file's values in detail, you may use the config:show Artisan command
php artisan config:show databaseTo encrypt an environment file, you may use the env:encrypt command
php artisan env:encryptYou may encrypt a specific environment file using the --env flag
php artisan env:encrypt --env=stagingTo decrypt an environment file, you may use the env:decrypt command
php artisan env:decryptYou may decrypt a specific environment file using the --env flag
php artisan env:decrypt --env=stagingIn order to overwrite an existing environment file, you may provide the --force option to the env:decrypt command
php artisan env:decrypt --forceThis command may be used to purge the cached configuration
php artisan config:clearTo cache your current configuration, you may use the config:cache Artisan command, The command should not be run during local development as configuration options will frequently need to be changed during the course of your application's development
php artisan config:cacheTo cache your events and listeners, you may use the event:cache command
php artisan event:cacheTo cache your application's routes, you may use the route:cache Artisan command
php artisan route:cacheTo clear your route cache, you may use the route:clear command
php artisan route:clearTo cache your Blade views, you may use the view:cache Artisan command
php artisan view:cacheTo clear the view cache, you may use the view:clear command
php artisan view:clearEnable Maintenance Mode:
php artisan downEnable Maintenance Mode with Auto Refresh (15 seconds):
php artisan down --refresh=15Enable Maintenance Mode with Retry-After Header (60 seconds):
php artisan down --retry=60Enable Maintenance Mode with Secret Token to Bypass:
php artisan down --secret="1630542a-246b-4b66-afa1-dd72a4c43515"Enable Maintenance Mode with Custom View:
php artisan down --render="errors::503"Enable Maintenance Mode with Redirect to a Different URL:
php artisan down --redirect=/Bring the Application Out of Maintenance Mode:
php artisan upView a List of All Available Commands:
php artisan list makeView a List of All Available Commands with JSON Output Format:
php artisan list make --format=jsonTo optimize Composer's autoloader, you may use the optimize-autoloader command
composer install --optimize-autoloader --no-dev To create a service provider, use the make:provider command
php artisan make:provider RiakServiceProvider View a List of All Registered Routes for the Application:
php artisan route:listView More Details About Each Route (Including Route Middleware):
php artisan route:list -vView Even More Details About Each Route (Including Route Middleware):
php artisan route:list -vvView a List of All Registered Routes for the Application Except Vendor Routes:
php artisan route:list --except-vendorView a List of All Registered Vendor Routes:
php artisan route:list --only-vendorCreate a New Middleware:
php artisan make:middleware EnsureTokenIsValidCreate a New View:
php artisan make:view greetingCreate a New Component:
php artisan make:component AlertCreate a New Component within a Subdirectory:
php artisan make:component Forms/InputCreate a New Component with a Custom View:
php artisan make:component forms.input --viewCreate a New Component with an Inline View:
php artisan make:component Alert --inlineGenerate a Migration that Creates the Sessions Table:
php artisan session:tableCreate a New Form Request Class:
php artisan make:request StorePostRequestCreate a New Validation Rule:
php artisan make:rule UppercaseCreate a New Implicit Validation Rule:
php artisan make:rule Uppercase --implicitPublish the Error Views Used by the Default Exception Handler:
php artisan vendor:publish --tag=laravel-errorsLaravel Pail is a package that allows you to easily dive into your Laravel application's log files directly from the command line. Unlike the standard tail command, Pail is designed to work with any log driver, including Sentry or Flare. In addition, Pail provides a set of useful filters to help you quickly find what you're looking for.
Install the laravel/pail Composer Package:
composer require laravel/pailStart Tailing Logs:
php artisan pailIncrease the Verbosity of the Output (Avoid Truncation):
php artisan pail -vMaximum Verbosity (Display Exception Stack Traces):
php artisan pail -vvFilter Logs by a Given String:
php artisan pail --filter="production"Filter Logs by a Given Message:
php artisan pail --message="User created"Filter Logs by a Given Level:
php artisan pail --level=errorFilter Logs by a Given User ID:
php artisan pail --user=1View a List of All Available Artisan Commands:
php artisan listView More Information About a Given Command:
php artisan help migrateLaravel Tinker is a powerful REPL for the Laravel framework, powered by the PsySH package
Install the laravel/tinker Composer Package:
composer require laravel/tinkerEnter the Tinker REPL:
php artisan tinkerPublish Tinker's Configuration File:
php artisan vendor:publish --provider="Laravel\Tinker\TinkerServiceProvider"In addition to the commands provided with Artisan, you may build your own custom commands.
Create a New Command:
php artisan make:command SendEmailsRun a Command in Isolation:
php artisan mail:send 1 --isolatedRun a Command in Isolation for a Given Number of Seconds:
php artisan mail:send 1 --isolated=12Queue a Command:
php artisan mail:send 1 --queueQueue a Command on a Specific Queue:
php artisan mail:send 1 --queue=defaultQueue a Command on a Specific Queue (Using -Q Flag):
php artisan mail:send 1 -QdefaultRun a Command on Multiple Connections or Queues (Multiple Arguments):
php artisan mail:send 1 2Run a Command on Multiple Connections or Queues (Using Multiple --id Flags):
php artisan mail:send --id=1 --id=2Publish All of the Package's Stubs:
php artisan stub:publishInstall the pusher/pusher-php-server Composer Package:
composer require pusher/pusher-php-serverInstall the ably/ably-php Composer Package:
composer require ably/ably-phpInstall the laravel-echo and pusher-js Packages:
npm install --save-dev laravel-echo pusher-jsView a List of All Registered Channels:
php artisan channel:listCreate a New Channel:
php artisan make:channel OrderChannelGenerate All Events and Listeners for Your Application:
php artisan event:generateCreate a New Event Class:
php artisan make:event PodcastProcessedCreate a New Event Listener:
php artisan make:listener SendPodcastNotification --event=PodcastProcessedCreate the Symbolic Link for Storage:
php artisan storage:linkInstall the league/flysystem-aws-s3-v3 Composer Package:
composer require league/flysystem-aws-s3-v3 "^3.0" --with-all-dependenciesInstall the league/flysystem-ftp Composer Package:
composer require league/flysystem-ftp "^3.0"Install the league/flysystem-sftp-v3 Composer Package:
composer require league/flysystem-sftp-v3 "^3.0"Install the league/flysystem-path-prefixing Composer Package:
composer require league/flysystem-path-prefixing "^3.0"Install the league/flysystem-read-only Composer Package:
composer require league/flysystem-read-only "^3.0"Install the spatie/flysystem-dropbox Composer Package:
composer require spatie/flysystem-dropboxInstall the guzzlehttp/guzzle Composer Package:
composer require guzzlehttp/guzzlePublish All of the Package's Language Files:
php artisan lang:publishInstall the symfony/mailgun-mailer and symfony/http-client Composer Packages:
composer require symfony/mailgun-mailer symfony/http-clientInstall the symfony/postmark-mailer and symfony/http-client Composer Packages:
composer require symfony/postmark-mailer symfony/http-clientInstall the aws/aws-sdk-php Composer Package:
composer require aws/aws-sdk-phpInstall the mailersend/laravel-driver Composer Package:
composer require mailersend/laravel-driverCreate a New Mailable Class:
php artisan make:mail OrderShippedCreate a New Mailable Class with a Markdown Template:
php artisan make:mail OrderShipped --markdown=emails.orders.shippedPublish the Mail Configuration File:
php artisan vendor:publish --tag=laravel-mailInstall the symfony/brevo-mailer and symfony/http-client Composer Packages:
composer require symfony/brevo-mailer symfony/http-clientCreate a New Notification Class:
php artisan make:notification InvoicePaidPublish the Notification Configuration File:
php artisan vendor:publish --tag=laravel-notificationsCreate a New Notification Class with a Markdown Template:
php artisan make:notification InvoicePaid --markdown=mail.invoice.paidPublish the Mail Configuration File:
php artisan vendor:publish --tag=laravel-mailGenerate a Migration to Create the Notifications Table:
php artisan notifications:tableInstall the laravel/slack-notification-channel Composer Package:
composer require laravel/slack-notification-channelTo start the worker, you may use the queue:work command:
php artisan queue:work --queue=high,defaultTo generate a migration that creates the jobs table, use the queue:table command:
php artisan queue:tableTo create a new job class, use the make:job Artisan command:
php artisan make:job ProcessPodcastTo specify the maximum number of times a job should be attempted, you may use the --tries switch on the queue:work command:
php artisan queue:work --tries=3To specify the maximum number of seconds a child process can run, you may use the --timeout switch on the queue:work command:
php artisan queue:work --timeout=30To generate a migration that creates the batches table, use the queue:batches-table command:
php artisan queue:batches-tableTo start the worker, you may use the queue:work command:
php artisan queue:workTo increase the verbosity of the worker's output, you may use the -v option:
php artisan queue:work -vStart the Worker in "Listen" Mode:
php artisan queue:listenStart the Worker for a Specific Connection (e.g., Redis):
php artisan queue:work redisStart the Worker for a Specific Queue (e.g., emails):
php artisan queue:work redis --queue=emailsProcess Only the Next Job on the Queue:
php artisan queue:work --onceProcess a Specific Number of Jobs:
php artisan queue:work --max-jobs=1000Stop the Worker When the Queue is Empty:
php artisan queue:work --stop-when-emptyStop the Worker After a Specified Time:
php artisan queue:work --max-time=3600Specify the Number of Seconds to Wait Before Polling for New Jobs:
php artisan queue:work --sleep=3Specify Multiple Queues for the Worker to Listen On:
php artisan queue:work --queue=high,lowRestart All Queue Workers:
php artisan queue:restartGenerate a Migration to Create the Failed Jobs Table:
php artisan queue:failed-tableSpecify the Maximum Number of Attempts for a Job on Redis:
php artisan queue:work redis --tries=3Specify the Backoff Time for Retries on Redis:
php artisan queue:work redis --tries=3 --backoff=3View All Failed Jobs:
php artisan queue:failedRetry All Failed Jobs for a Specific Queue:
php artisan queue:retry --queue=nameRetry All Failed Jobs:
php artisan queue:retry allRetry a Specific Failed Job:
php artisan queue:retry 5Delete a Specific Failed Job:
php artisan queue:forget 5Delete All Failed Jobs:
php artisan queue:flushPrune Failed Jobs Older Than a Given Number of Days:
php artisan queue:prune-failedPrune Failed Jobs Older Than a Given Number of Hours:
php artisan queue:prune-failed --hours=48Run the Worker in Daemon Mode:
php artisan queue:work --daemonInstall the aws/aws-sdk-php Composer Package:
composer require aws/aws-sdk-phpDelete All Jobs from a Given Queue:
php artisan queue:clearDelete All Jobs from a Specific Queue (e.g., emails):
php artisan queue:clear --queue=emailsDelete All Jobs from a Specific Queue (e.g., emails) on a Specific Connection (e.g., Redis):
php artisan queue:clear redis --queue=emailsphp artisan queue:monitor redis:default,redis:deployments --max=100View All Scheduled Tasks:
php artisan schedule:listInterrupt a Scheduled Task:
php artisan schedule:interruptRun Your Scheduled Tasks:
php artisan schedule:runRun the Scheduler in the Background:
php artisan schedule:workCreate a New Policy:
php artisan make:policy PostPolicyCreate a New Policy for a Model (e.g., Post):
php artisan make:policy PostPolicy --model=PostRun All Outstanding Migrations:
php artisan migrateView a List of All Available Artisan Commands:
php artisan dbView a List of Available Artisan Commands for MySQL:
php artisan db mysqlView a List of All Database Connections Configured for the Application:
php artisan db:showInspect a Specific Database Connection (e.g., PostgreSQL):
php artisan db:show --database=pgsqlInclude Table Row Counts and View Details in the Output:
php artisan db:show --counts --viewsView the Table Definition for a Given Table (e.g., users):
php artisan db:table usersMonitor Database Connections (e.g., MySQL, PostgreSQL):
php artisan db:monitor --databases=mysql,pgsql --max=100Create the Migration Repository:
php artisan migrate:installCreate a New Migration (e.g., create_flights_table):
php artisan make:migration create_flights_tableCreate a Migration to Modify an Existing Table (e.g., add_votes_to_users_table):
php artisan make:migration add_votes_to_users_table --table=usersDump the Database Schema:
php artisan schema:dumpDump the Database Schema Without Comments:
php artisan schema:dump --pruneDump the Database Schema Without Comments for a Specific Database (e.g., testing):
php artisan schema:dump --database=testing --pruneView the Status of Your Migrations:
php artisan migrate:statusRun Migrations Without Actually Running Them (Pretend Mode):
php artisan migrate --pretendRun Migrations in Isolation:
php artisan migrate --isolatedRun Migrations Without a Prompt (Force):
php artisan migrate --forceRollback the Latest Migration Operation:
php artisan migrate:rollbackRollback the Last Five Migrations:
php artisan migrate:rollback --step=5Rollback Migrations by a Specific Batch (e.g., batch 3):
php artisan migrate:rollback --batch=3Rollback Migrations Without Actually Running Them (Pretend Mode):
php artisan migrate:rollback --pretendRollback All Migrations:
php artisan migrate:resetRollback All Migrations and Then Execute the Migrate Command:
php artisan migrate:refreshRollback All Migrations and Execute the Migrate Command with Seeding:
php artisan migrate:refresh --seedRollback All Migrations and Execute the Migrate Command with a Step Option:
php artisan migrate:refresh --step=5Drop All Tables and Re-run All Migrations:
php artisan migrate:freshDrop All Tables and Re-run All Migrations with Seeding:
php artisan migrate:fresh --seedCreate a New Seeder:
php artisan make:seeder UserSeederSeed the Database:
php artisan db:seedSeed a Specific Seeder Class (e.g., UserSeeder):
php artisan db:seed --class=UserSeederDrop All Tables and Re-run All Migrations and Seeds:
php artisan migrate:fresh --seedDrop All Tables and Re-run All Migrations and Specific Seeder (e.g., UsersTableSeeder):
php artisan migrate:fresh --seed --seeder=UsersTableSeederSeed the Database Without a Prompt:
php artisan db:seed --forceInstall the Predis Composer Package:
composer require predis/predisView a List of All Available Artisan Redis Commands:
php artisan redis:commandScan for Redis Commands:
php artisan redis:command --scanCreate a New Model:
php artisan make:model FlightCreate a New Model and Its Migration:
php artisan make:model Flight --migrationView a List of All Available Artisan Model Commands:
php artisan model:show FlightCreate a New Model and Its Factory:
php artisan make:model Flight --factoryCreate a New Model and Its Factory (Using Short Option):
php artisan make:model Flight -fCreate a New Model and Its Seeder:
php artisan make:model Flight --seedCreate a New Model and Its Seeder (Using Short Option):
php artisan make:model Flight -sCreate a New Model and Its Controller:
php artisan make:model Flight --controllerCreate a New Model and Its Controller (Using Short Option):
php artisan make:model Flight -cCreate a New Model, Its Controller, Resource, and Requests:
php artisan make:model Flight --controller --resource --requestsCreate a New Model, Its Controller, Resource, and Requests (Using Short Option):
php artisan make:model Flight -crRCreate a New Model and Its Policy:
php artisan make:model Flight --policyCreate a New Model and Its Policy (Using Short Option):
php artisan make:model Flight -pCreate a New Model and Its Migration, Factory, Seeder, and Controller:
php artisan make:model Flight -mfscThis command combines multiple options to create the model with the following associated components:
- Migration (
-m) - Factory (
-f) - Seeder (
-s) - Controller (
-c)
Create a New Model and Its Migration, Factory, Seeder, Policy, Controller, and Form Requests:
php artisan make:model Flight --allCreate a New Pivot Model:
php artisan make:model Member --pivotCreate a New Pivot Model (Using Short Option):
php artisan make:model Member -pPrune Models Without Corresponding Database Tables:
php artisan model:prune --pretendCreate a New Scope:
php artisan make:scope AncientScopeCreate a New Scope for a Specific Model:
php artisan make:scope AncientScope --model=FlightCreate a New Observer:
php artisan make:observer UserObserver --model=UserCreate a New Cast:
php artisan make:cast JsonCreate a New Inbound Cast (Applied when setting a value on the model):
php artisan make:cast Hash --inboundCreate a New Resource:
php artisan make:resource UserResourceCreate a New Resource Collection (Using the --collection option):
php artisan make:resource User --collectionCreate a New Resource Collection:
php artisan make:resource UserCollectionCreate a New Factory:
php artisan make:factory FlightFactoryCreate a New Test:
php artisan make:test UserTestCreate a New Unit Test:
php artisan make:test UserTest --unitCreate a New Pest Test:
php artisan make:test UserTest --pestCreate a New Unit Test with Pest:
php artisan make:test UserTest --unit --pestRun Tests:
php artisan testRun a Specific Test Suite and Stop on Failure:
php artisan test --testsuite=Feature --stop-on-failureGenerate a Code Coverage Report:
php artisan test --coverageGenerate a Code Coverage Report with Minimum Coverage:
php artisan test --coverage --min=80.3Generate a Performance Profile:
php artisan test --profileInstall All of the Project's Dependencies:
npm installCompile Your Assets for Development:
npm run devCompile Your Assets for Production:
npm run build