Powerful digital products, engineered in Kerala for organisations everywhere.
+91 95399 51353 opsintech@icloud.com Privacy + data protection
← Back to the journal Laravel Artisan

Laravel Artisan command guide for development and deployment

A copy-ready Laravel command reference for Artisan discovery, generators, routes, configuration, migrations, caches, tests, queues, and scheduled tasks.

Editorial image for Laravel Artisan command guide for development and deployment
Laravel Artisan / OpsinTech insight
01

Step 1: discover commands in the installed Laravel version

Run Artisan from the application root. Available commands and options can vary by Laravel version and installed packages, so list and help are the most reliable starting points.

Show application information

Summarizes the application environment, Laravel and PHP versions, cache state, drivers, and installed packages.

php artisan about
When to use itUse first when diagnosing an unfamiliar application or comparing environments.

List available commands

Displays every Artisan command registered by Laravel, the application, and installed packages.

php artisan list
When to use itUse to confirm that a command exists in the current project before copying an example.

Read command-specific help

Shows the selected command’s arguments, options, and description without executing it.

php artisan help migrate
When to use itReplace migrate with any command name to verify its supported flags.

Run Artisan through Laravel Sail

Runs Artisan inside the Sail application container instead of using the host PHP runtime.

./vendor/bin/sail artisan list
When to use itUse this form when the project is configured for Laravel Sail.
02

Step 2: generate common application classes

Generators create framework-aware boilerplate in conventional locations. Review every generated file, add authorization and validation deliberately, and commit only the classes the feature needs.

Create a model and migration

Creates an Eloquent model and a matching migration file.

php artisan make:model Invoice --migration
When to use itUse when introducing a new persistent domain record.

Create a resource controller

Creates a resource-style controller with methods type-oriented around the named model.

php artisan make:controller InvoiceController --resource --model=Invoice
When to use itUse for conventional create, read, update, and delete HTTP workflows.

Create a form request

Creates a dedicated request class for authorization and validation rules.

php artisan make:request StoreInvoiceRequest
When to use itUse instead of growing complex inline validation inside a controller.

Create a feature test

Creates a feature test in the project’s test suite.

php artisan make:test InvoiceManagementTest
When to use itUse to cover an end-to-end HTTP or application workflow.

Create an Artisan command

Creates a custom console command class under the application console-command directory.

php artisan make:command ReconcileInvoices
When to use itUse for an explicit operational task; keep business logic in an application service that the command calls.
03

Step 3: inspect routes, configuration, storage, and runtime data

Prefer read-only inspection before clearing caches or modifying data. Never copy secrets printed from configuration or interactive sessions into tickets, logs, or shared notes.

List application routes

Displays application routes while hiding routes registered by third-party packages.

php artisan route:list --except-vendor
When to use itUse to inspect methods, URIs, route names, middleware, and controllers.

Filter routes by path

Limits route output to URIs matching the provided path text.

php artisan route:list --path=api
When to use itUse when investigating API routing without scanning the entire table.

Inspect one configuration file

Displays resolved values for the selected configuration file.

php artisan config:show database
When to use itUse locally to confirm the active database driver and connection structure.
CautionConfiguration output may contain sensitive values. Do not paste it into public logs or documentation.

Open the application REPL

Starts an interactive shell with the Laravel application booted.

php artisan tinker
When to use itUse for careful model queries or service experiments in a local environment.
CautionTinker can modify real application data. Verify the environment before running write operations.

Create the public storage link

Creates the configured symbolic link from public storage to application-managed files.

php artisan storage:link
When to use itUse during environment setup when public uploads are stored on the local disk.
04

Step 4: review and run database migrations

Back up production data and review migration SQL before deployment. A rollback is only safe when each migration’s down method accurately reverses its change.

Check migration status

Shows which migration files have run and which remain pending.

php artisan migrate:status
When to use itUse before and after every migration deployment.

Preview migration SQL

Prints the SQL that pending migrations would execute without applying it.

php artisan migrate --pretend
When to use itUse during review to catch unexpected table or index operations.

Run pending migrations

Executes all pending migrations against the configured database.

php artisan migrate
When to use itUse through the project’s reviewed deployment process after backup and SQL review.

Preview and roll back one migration step

The first command previews rollback SQL; the second rolls back the most recent migration step.

php artisan migrate:rollback --step=1 --pretend
php artisan migrate:rollback --step=1
When to use itUse only when the targeted down migration is reviewed and the data-loss impact is understood.
CautionDestructive: rollback operations can remove columns, tables, indexes, and data.

Rebuild a disposable local database

Drops every table, reruns all migrations, and executes database seeders.

php artisan migrate:fresh --seed
When to use itUse for a disposable local or automated-test database only.
CautionHighly destructive: never run against production or a shared database.
05

Step 5: manage deployment caches

Optimization commands belong in a controlled deployment workflow. Configuration caching changes how environment values are resolved, so env calls should remain inside configuration files.

Build production optimization caches

Caches framework bootstrap information such as configuration, events, routes, and views for production.

php artisan optimize
When to use itRun during deployment after dependencies and environment configuration are ready.

Clear optimization caches

Removes files generated by optimization and clears keys from the default cache store.

php artisan optimize:clear
When to use itUse while diagnosing stale deployment state or before rebuilding caches.
CautionThis also affects the default application cache store; understand the operational impact first.

Cache configuration only

Combines application configuration into one cached file for faster production loading.

php artisan config:cache
When to use itUse as part of production deployment, not routine local development.

Cache routes and views separately

Caches route registration and precompiles Blade templates.

php artisan route:cache
php artisan view:cache
When to use itUse when a deployment pipeline manages optimization components individually.
06

Step 6: generate and run tests

Run the narrowest useful test while developing, then run the complete suite before merging. Laravel forwards supported Pest or PHPUnit options through the Artisan test runner.

Run the complete test suite

Runs the configured Pest or PHPUnit suite with Laravel’s console reporting.

php artisan test
When to use itUse before pushing or merging a completed change.

Run the feature suite

Runs one named test suite and stops after its first failure.

php artisan test --testsuite=Feature --stop-on-failure
When to use itUse for quick feedback while working on HTTP or integration behavior.

Filter to one test

Runs tests whose class or method names match the provided filter.

php artisan test --filter=InvoiceManagementTest
When to use itReplace the example name with the test currently being developed.

Find slow tests

Runs tests and reports the slowest cases for investigation.

php artisan test --profile
When to use itUse when suite duration begins slowing down local and continuous-integration feedback.
07

Step 7: operate queues and scheduled tasks

Production workers need a process monitor, and deployments must restart long-running workers so they load new code. Coordinate worker timeouts with the queue connection’s retry_after setting.

Run a development queue worker

Starts a long-running worker with explicit attempt and timeout limits.

php artisan queue:work --tries=3 --timeout=60
When to use itUse locally or under a configured production process monitor.

Restart workers gracefully

Signals workers to exit after their current job so a process monitor can start fresh processes.

php artisan queue:restart
When to use itRun during deployment after the new application code is ready.

Inspect scheduled tasks

Lists scheduled tasks and their next expected run times.

php artisan schedule:list
When to use itUse to verify that application schedules are registered as intended.

Run the scheduler locally

Runs the scheduler in the foreground and evaluates due tasks each minute.

php artisan schedule:work
When to use itUse during local development instead of installing a machine-level cron entry.
REF

Further reading

Related OpsinTech solutions
ServiceCustom Software ServiceManaged Web Hosting & Cloud