The Skeleton of Laravel Project Structure
Here are the complete steps to install Laravel and get your local development environment up and running from scratch.
Laravel is a PHP framework, so your machine needs PHP and a couple of essential tools installed first.
PHP: Ensure you have PHP 8.2 or higher installed on your system.
Composer: This is the dependency manager for PHP (similar to npm for Node.js). Download and install it from "https://getcomposer.org/".
To verify they are installed correctly, open your terminal (or Command Prompt) and run:
Bash
php -v
composer -v
The easiest way to create new Laravel projects is by installing the global Laravel installer via Composer. Run this command in your terminal:
Bash
composer global require laravel/installer
Note for Windows/macOS Users: Make sure your system's global Composer binaries directory is in your system's
PATHvariable so your terminal recognizes thelaravelcommand.
Navigate to the directory where you want to keep your projects (e.g., cd Documents/Projects), and run the installation command:
Bash
laravel new my-first-app
When you run this, the interactive installer will ask you a few setup questions to tailor your installation:
Which frontend installer would you like to use?
No starter kit: Choose this if you want a clean slate (perfect for APIs or custom full-stack setups).
Breeze: Highly recommended for beginners. It instantly scaffolds a clean authentication system (Login/Register) using Blade, Livewire, Vue, or React.
Which testing framework do you prefer?
Pest (modern and highly readable) or PHPUnit (the classic standard).
Would you like to initialize a Git repository?
Yes/No (Choosing Yes is highly recommended for version control).
Which database database engine will you use?
SQLite, MySQL, PostgreSQL, etc. (SQLite is fantastic for local development because it requires zero configuration).
The installer will download all the necessary files and build your project skeleton.
Once the installation completes, navigate into your new project directory:
Bash
cd my-first-app
To start Laravel's built-in local development server, execute the Artisan command:
Bash
php artisan serve
Your terminal will show that the server is running. Open your web browser and navigate to:
http://127.0.0.1:8000
You will be greeted by the official Laravel welcome screen!
If you chose SQLite during Step 3, Laravel has already created a database file (database/database.sqlite) and configured it for you.
If you chose MySQL or PostgreSQL, open your project folder in your code editor (like VS Code), open your .env file, and update your database credentials:
Code snippet
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=my_first_app_db
DB_USERNAME=root
DB_PASSWORD=your_password
Once your database credentials match your local database server, run your first set of migrations to build the native user tables:
Bash
php artisan migrate
Your installation is now complete and fully connected to your database.
You can see every single command available in your specific installation by typing php artisan list or simply php artisan in your terminal.
Because Laravel has over 100 built-in commands, printing them all out would create a massive wall of text. Instead, here is a categorized cheat sheet of the most essential and frequently used Artisan commands you will actually use day-to-day.
| Command | What it does |
|---|---|
php artisan serve |
Starts the local PHP development server (usually at localhost:8000). |
php artisan tinker |
Opens an interactive REPL shell to test database queries and PHP code on the fly. |
php artisan env |
Displays the current application environment (local, production, etc.). |
php artisan about |
Gives a comprehensive overview of your app configuration, drivers, and versions. |
make: Group (Code Scaffolding)Instead of creating files manually, use these commands to automatically generate boilerplate classes with proper namespaces in the correct directories.
| Command | What it does |
|---|---|
php artisan make:controller PostController |
Creates a regular Controller in app/Http/Controllers. |
php artisan make:controller PostController --api |
Creates an API controller with resource methods (minus create/edit). |
php artisan make:model Post |
Creates an Eloquent model in app/Models. |
php artisan make:model Post -mcr |
Pro Tip: Generates the Model, Database Migration, Resource Controller, and Factory all at once. |
php artisan make:migration create_posts_table |
Generates a structural database version-control schema file. |
php artisan make:seeder PostSeeder |
Creates a database seeder file. |
php artisan make:factory PostFactory |
Creates a fake data generation factory. |
php artisan make:middleware CheckAge |
Generates an HTTP request filtering middleware. |
php artisan make:resource PostResource |
Generates an API Resource transformer for data clean-up. |
migrate: & db:)| Command | What it does |
|---|---|
php artisan migrate |
Runs all pending database migrations to build or update your tables. |
php artisan migrate:rollback |
Reverts the last batch of database migrations. |
php artisan migrate:fresh |
Drops all tables completely and runs all migrations from scratch (destroys data). |
php artisan migrate:fresh --seed |
Wipes the database, rebuilds it, and populates it with your initial seed data. |
php artisan db:seed |
Runs the seeders to populate tables with mockup or default data. |
php artisan db:wipe |
Drops all tables, views, and types without re-running migrations. |
| Command | What it does |
|---|---|
php artisan route:list |
Displays a clear table of all registered routes, HTTP methods, and names. |
php artisan route:cache |
Caches your routes for lightning-fast parsing (use mostly in production). |
php artisan route:clear |
Deletes the compiled route cache file. |
php artisan config:cache |
Combines all config files into a single file for speed optimization. |
php artisan config:clear |
Clears the application configuration cache. |
php artisan optimize:clear |
Wipes caches for configuration, routes, views, and compiled classes all at once. |
| Command | What it does |
|---|---|
php artisan down |
Puts the app into maintenance mode (shows a "503 Service Unavailable" page to users). |
php artisan up |
Takes the app out of maintenance mode, making it live again. |
php artisan storage:link |
Creates a symbolic link from public/storage to storage/app/public so uploaded files are web-accessible. |
php artisan key:generate |
Sets the APP_KEY in your .env file to encrypt sessions and cookies securely. |
Pro Tip: If you ever forget how a command works or what arguments it accepts, just prefix it with
help. For example:php artisan help migrate:fresh.
Navigating a fresh Laravel installation can feel a bit like walking into a massive, multi-room workshop. Everything has a specific place, and knowing where things live will save you hours of searching.
Here is a breakdown of the Laravel project skeleton, focusing on the directories you will interact with the most.
app/Directory (The Brains)This is the heart of your application. It contains the core PHP code for your project.
Http/Controllers/: Where you handle incoming HTTP requests and pass data to views.
Models/: Contains your Eloquent model classes (each table in your database usually has a corresponding Model to interact with it).
Providers/: Service Providers. These "bootstrap" your application by binding things into Laravel's service container.
routes/Directory (The Traffic Controller)This directory contains all the route definitions for your application.
web.php: Where you define routes for your web interface. These routes are assigned the web middleware group, which provides features like session state and CSRF protection.
api.php: Where you define routes for your API. These routes are stateless and usually use token authentication.
console.php: Where you define your closure-based console commands.
resources/Directory (The Face)This directory contains your front-end assets and raw, un-compiled files.
views/: Contains your HTML templates, typically using Laravel's Blade templating engine (e.g., welcome.blade.php).
css/ & js/: Your raw frontend assets before they are compiled by Vite or Laravel Mix.
database/Directory (The Backbone)Everything related to your database setup lives here.
migrations/: Database version control. These files define your database schema so it can be easily recreated on any machine.
factories/: Used to generate large amounts of fake data for testing or seeding.
seeders/: Used to populate your database with initial data (like an admin user or a list of countries).
config/ Directory (The Control Panel)As the name implies, this contains all of your application's configuration files (e.g., app.php, database.php, mail.php). Most of these files pull their actual values from your hidden .env file at the root of the project.
.env: The Environment Configuration file. This is where you store sensitive data like database credentials, API keys, and app environment settings (local vs production). Never commit this file to Git.
composer.json: Manages your PHP dependencies (libraries and packages required by Laravel).
artisan: The command-line interface for Laravel. You use it by running php artisan [command] in your terminal to generate code, run migrations, or clear caches.
To understand how a full-stack Laravel application functions, it helps to look at it as a unified ecosystem where the backend logic and the frontend user interface are tightly coupled.
Laravel shines as a full-stack framework because it manages everything from database queries to HTML rendering under one roof.
When a user interacts with a full-stack Laravel application, the request moves through a predictable, circular cycle:
[ Browser ] ──( HTTP Request )──> [ routes/web.php ]
▲ │
│(HTML / CSS / JS) (Dispatches)
│ ▼
[ Blade View ]<──( Passes Data ) ── [ Controller ]
│
(Queries / Saves)
â–¼
[ DB / Model ]
The Request: A user clicks a link or submits a form, sending an HTTP request to your server.
The Route: The request hits routes/web.php, which determines which Controller should handle it.
The Controller: The controller processes business logic. It talks to your Eloquent Models to fetch or save data in the database.
The View: The controller takes that data and passes it to a Blade template (resources/views/).
The Response: The server compiles the Blade template into standard HTML and sends it back to the user's browser.
A robust full-stack Laravel application relies on a few core pillars to handle data, logic, and presentation efficiently.
Laravel strictly adheres to the MVC architectural pattern to separate concerns:
Model ($M$): Represents your data structure and business rules. If you have a users table, you have a User.php model to interact with it.
View ($V$): The presentation layer (HTML/CSS). In Laravel, this is powered by the Blade engine.
Controller ($C$): The glue. It accepts user input from the View, commands the Model to manipulate data, and updates the View.
Modern full-stack Laravel applications use Vite to asset-bundle frontend code. When you write modern JavaScript or use utility-first CSS frameworks like Tailwind CSS, Vite watches your files in real-time, compiles them, and injects them instantly into your Blade views.
Because it is full-stack, Laravel handles user sessions natively. It uses secure, encrypted cookies to keep users logged in, flash temporary "success" messages across pages, and protect against Cross-Site Request Forgery (CSRF) via native @csrf Blade tokens.
While standard Blade templates work perfectly for traditional apps, the Laravel ecosystem offers advanced architectural flavors depending on how "reactive" you want your frontend to feel:
How it works: Laravel renders HTML on the server. You use Tailwind for styling and Alpine.js for minor JavaScript sprinkles (like dropdowns or mobile menus).
Best for: Content-heavy sites, blogs, e-commerce, and SEO-focused applications.
How it works: Livewire allows you to build dynamic, real-time user interfaces using only PHP. When a user clicks a button, Livewire makes a seamless AJAX request behind the scenes and updates the page without a full browser reload.
Best for: Dashboards, complex forms, and dynamic web applications where you want to avoid writing complex API layers and JavaScript.
How it works: Inertia bridges the gap between Laravel and modern JavaScript frameworks. You use Vue or React to build your entire frontend, but you use standard Laravel routing and controllers instead of building a separate client-side router or REST API.
Best for: Rich, highly interactive single-page applications where you prefer Vue or React but love Laravel's backend simplicity.
When you choose to use Laravel strictly as a Headless Backend API, the architecture shifts drastically away from rendering web pages. Instead, Laravel serves as a high-performance, stateless data machine. Your frontend (whether it is a React/Next.js SPA, a Vue app, or a mobile app) lives entirely independently, communicating with Laravel exclusively through HTTP requests.
In a headless architecture, Laravel doesn't care what the frontend looks like or what technology it uses. It only cares about inputs and outputs—typically formatted as JSON.
[ Frontend App ] ──( HTTP Request: GET /api/users )──> [ routes/api.php ]
▲ │
│ (Routes to)
│(JSON Response) ▼
[ API Resource ] <──( Transforms )── [ Model ] <── [ Controller ]
The Request: The frontend application makes an asynchronous network call (using fetch, Axios, etc.) to an API endpoint, passing along authentication tokens and data payload if necessary.
The Routing & Middleware: The request enters through routes/api.php. It passes through the api middleware group, which handles rate limiting, CORS (Cross-Origin Resource Sharing), and token authentication (via Laravel Sanctum).
The Controller: The controller handles the request, interacting with Eloquent Models to fetch, store, or modify data in the database.
The Transformation (API Resources): Instead of passing raw database data or models directly back to the user, Laravel uses API Resources to format and clean the data into a structured JSON response.
The Response: Laravel sends a raw JSON payload back to the frontend along with an appropriate HTTP status code (e.g., 200 OK, 201 Created, 401 Unauthorized).
When you transition Laravel into a Headless Backend API architecture, you strip away the frontend rendering responsibilities (the "head") and treat Laravel purely as a data-engine and business-logic service.
The frontend becomes a completely independent application—built with frameworks like Next.js, Nuxt, React, iOS, or Android—that communicates with Laravel exclusively over HTTP.
In a headless architecture, Laravel never sends back HTML. Instead, it receives requests containing JSON or form data, processes it, and returns structured data (usually JSON) along with standardized HTTP status codes.
[ Independent Frontend ] ──( HTTP Request with JSON / Token )──> [ routes/api.php ]
▲ │
│ (Middleware)
│(JSON Response: e.g., 200 OK) ▼
[ API Resource ] <──( Formats Data )── [ Controller ] <─── [ Auth & Guard ]
│
(Model / DB)
The Request: The frontend application makes an asynchronous network call (fetch or axios) to a Laravel URL (e.g., https://api.myapp.com/v1/posts).
The API Route & Middleware: The request enters through routes/api.php. It bypasses web features like sessions and cookies, running instead through the api middleware group (which handles rate limiting and token authentication).
Authentication/Guard: If the route is protected, middleware verifies the incoming API key or Bearer Token (via Laravel Sanctum or Passport).
The Controller & Model: The Controller executes business logic, interacts with Eloquent Models, and retrieves database records.
The API Resource: Instead of a View, data is passed through an API Resource layer that formats the PHP objects into clean, predictable JSON arrays.
The Response: Laravel issues an HTTP response with a JSON payload and an appropriate status code (e.g., 200 OK, 201 Created, or 422 Unprocessable Entity).
To build a secure and performant headless backend, Laravel introduces or reconfigures several key architectural layers:
routes/api.php)Routes defined here are completely stateless. Because there are no sessions to remember who a user is between requests, every single incoming request must prove its identity by attaching a secure cryptographic token to the HTTP header.
Laravel provides two robust, native options for managing API security:
Laravel Sanctum: A lightweight, easy-to-use authentication system. Perfect for Single Page Applications (SPAs), mobile apps, and simple token-based API keys.
Laravel Passport: A full, heavy-duty OAuth2 server implementation. Use this if your backend needs to allow third-party applications to integrate and authenticate with your platform (like how apps allow you to "Log in with GitHub").
You should never return a raw database model directly from your controller, as it can accidentally leak sensitive internal columns (like password or remember_token).
Laravel uses API Resources to act as a transformation layer between your Eloquent models and the JSON responses returned to the user. It allows you to precisely shape the JSON structure, rename keys, and conditionally load database relationships.
Because your frontend and backend live on different domains or ports (e.g., myapp.com talking to api.myapp.com), modern browsers will block requests by default for security. Laravel includes built-in CORS configuration (config/cors.php) allowing you to specify exactly which frontend domains are permitted to talk to your backend.
In a full-stack app, a validation failure redirects the user back to the form with errors. In a headless app, Laravel automatically intercepts validation failures or exceptions and transforms them into standard JSON error objects accompanied by specific HTTP client error codes ($4xx$ or $5xx$).
When deploying a headless Laravel architecture, developers usually choose between two structural patterns:
| Feature | Monolith / Shared Host | Decoupled / Microservice |
| Setup | Frontend and Laravel API live in the same Git repository. | Frontend and Laravel live in completely separate repositories. |
| Deployment | Deployed together to a single server. | Frontend is deployed to an edge network (Vercel, Netlify), Laravel to a cloud server (AWS, DigitalOcean). |
| Auth Style | Sanctum cookie-based SPA authentication (highly secure, prevents XSS). | Sanctum token-based Bearer tokens (ideal for cross-domain or mobile applications). |
To see exactly how these two architectural philosophies differ, let’s look at a concrete, functional code example for a simple Product Management system.
Here is how the exact same feature is written across the files of a Full-Stack Application vs. a Headless Backend API.
In this setup, Laravel captures the request, retrieves the data, and renders an HTML page directly to the browser.
routes/web.php)PHP
<?php
use App\Http\Controllers\ProductController;
use Illuminate\Support\Facades\Route;
// Traditional web route returning a rendered HTML page
Route::get('/products', [ProductController::class, 'index'])->name('products.index');
app/Http/Controllers/ProductController.php)PHP
<?php
namespace App\Http\Controllers;
use App\Models\Product;
use Illuminate\View\View;
class ProductController extends Controller
{
/**
* Display a listing of products in a web view.
*/
public function index(): View
{
// Fetch active products from the database
$products = Product::where('is_active', true)->orderBy('name')->get();
// Pass data to resources/views/products/index.blade.php
return view('products.index', [
'products' => $products
]);
}
}
resources/views/products/index.blade.php)HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Our Store</title>
@vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<body class="bg-gray-100 p-8">
<div class="max-w-4xl mx-auto">
<h1 class="text-3xl font-bold mb-6 text-gray-800">Available Products</h1>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
@foreach ($products as $product)
<div class="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
<h2 class="text-xl font-semibold text-gray-900">{{ $product->name }}</h2>
<p class="text-gray-600 mt-2">{{ $product->description }}</p>
<span class="mt-4 inline-block font-bold text-emerald-600">${{ number_format($product->price, 2) }}</span>
</div>
@endforeach
</div>
</div>
</body>
</html>
In this setup, Laravel completely ignores the frontend. It returns clean, filtered JSON to whatever framework or application makes the HTTP call.
routes/api.php)PHP
<?php
use App\Http\Controllers\Api\ProductApiController;
use Illuminate\Support\Facades\Route;
// Stateless API route protected by Sanctum token middleware
Route::middleware('auth:sanctum')->get('/v1/products', [ProductApiController::class, 'index']);
app/Http/Resources/ProductResource.php)PHP
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class ProductResource extends JsonResource
{
/**
* Transform the model array into a predictable JSON structure.
*/
public function toArray(Request $request): array
{
// Explicitly format data, stripping away backend-only database columns
return [
'id' => $this->id,
'sku_number' => $this->sku,
'name' => $this->name,
'details' => $this->description,
'pricing' => [
'usd_amount' => $this->price,
'formatted' => '$' . number_format($this->price, 2),
]
];
}
}
app/Http/Controllers/Api/ProductApiController.php)PHP
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Resources\ProductResource;
use App\Models\Product;
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
class ProductApiController extends Controller
{
/**
* Return a collection of product resources as JSON.
*/
public function index(): AnonymousResourceCollection
{
$products = Product::where('is_active', true)->orderBy('name')->get();
// Pass data through the resource transformer layer
return ProductResource::collection($products);
}
}
When a mobile app or a Next.js client calls this API endpoint, they receive standard HTTP code 200 OK along with this raw string payload:
JSON
{
"data": [
{
"id": 14,
"sku_number": "PROD-9901",
"name": "Wireless Mechanical Keyboard",
"details": "Hot-swappable mechanical keyboard with custom linear switches.",
"pricing": {
"usd_amount": 129.99,
"formatted": "$129.99"
}
}
]
}
Let’s look at how both approaches handle data submission (creation), as this is where validation, state management, and security (like CSRF vs. Token validation) really highlight the architectural divide.
We will look at adding a new product to the database via a Full-Stack Form Submission vs. a Headless API JSON Payload.
In a full-stack architecture, the browser submits standard form data. If validation fails, Laravel redirects back to the previous page and flashes errors into the session. If it succeeds, it redirects to a success page.
routes/web.php)PHP
use App\Http\Controllers\ProductController;
use Illuminate\Support\Facades\Route;
Route::get('/products/create', [ProductController::class, 'create'])->name('products.create');
Route::post('/products', [ProductController::class, 'store'])->name('products.store');
resources/views/products/create.blade.php)HTML
<form action="{{ route('products.store') }}" method="POST" class="max-w-md bg-white p-6 rounded shadow">
@csrf
<h2 class="text-xl font-bold mb-4">Add New Product</h2>
@if ($errors->any())
<div class="bg-red-100 text-red-700 p-3 rounded mb-4 text-sm">
{{ $errors->first() }}
</div>
@endif
<div class="mb-4">
<label class="block text-sm font-medium">Product Name</label>
<input type="text" name="name" value="{{ old('name') }}" class="w-full border p-2 rounded">
</div>
<div class="mb-4">
<label class="block text-sm font-medium">Price ($)</label>
<input type="text" name="price" value="{{ old('price') }}" class="w-full border p-2 rounded">
</div>
<button type="submit" class="bg-blue-600 text-white px-4 py-2 rounded">Save Product</button>
</form>
app/Http/Controllers/ProductController.php)PHP
namespace App\Http\Controllers;
use App\Models\Product;
use Illuminate\Http\Request;
use Illuminate\Http\RedirectResponse;
class ProductController extends Controller
{
public function create()
{
return view('products.create');
}
public function store(Request $request): RedirectResponse
{
// 1. Validate incoming form data.
// If this fails, Laravel automatically redirects back with the errors.
$validated = $request->validate([
'name' => 'required|string|max:255',
'price' => 'required|numeric|min:0',
]);
// 2. Create the record
Product::create($validated);
// 3. Redirect back to the index page with a flash success message
return redirect()->route('products.index')
->with('success', 'Product created successfully!');
}
}
In a headless API architecture, the frontend (e.g., React or an iOS App) sends a POST request with a JSON body and a bearer token. Laravel returns explicit JSON, regardless of whether the operation succeeded or failed.
routes/api.php)PHP
use App\Http\Controllers\Api\ProductApiController;
use Illuminate\Support\Facades\Route;
Route::middleware('auth:sanctum')->post('/v1/products', [ProductApiController::class, 'store']);
app/Http/Controllers/Api/ProductApiController.php)PHP
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Resources\ProductResource;
use App\Models\Product;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
class ProductApiController extends Controller
{
public function store(Request $request): JsonResponse
{
// 1. Validate the JSON input.
// If this fails, Laravel automatically throws a ValidationException
// and returns a 422 Unprocessable Entity JSON response.
$validated = $request->validate([
'name' => 'required|string|max:255',
'price' => 'required|numeric|min:0',
]);
// 2. Create the record
$product = Product::create($validated);
// 3. Return a 201 Created status code along with the formatted JSON data
return (new ProductResource($product))
->response()
->setStatusCode(201);
}
}
If the frontend sends an invalid payload (for example, missing the name), Laravel bypasses web redirections and immediately spits out this machine-readable error payload:
JSON
{
"message": "The name field is required.",
"errors": {
"name": [
"The name field is required."
]
}
}
If the frontend sends a perfect payload, Laravel responds with a success status and the newly created resource:
JSON
{
"data": {
"id": 15,
"sku_number": "AUTOGEN-SKU",
"name": "Bluetooth Gaming Mouse",
"details": null,
"pricing": {
"usd_amount": 49.99,
"formatted": "$49.99"
}
}
}
To tie everything together, observe how your focus shifts depending on your choice of architecture:
| Component / Task | Full-Stack Web (routes/web.php) | Headless API (routes/api.php) |
| Security Layer | CSRF Tokens (@csrf) |
Bearer Tokens (Authorization: Bearer ...) |
| State Tracking | Encrypted Session Cookies | Stateless (Every request is independent) |
| Validation Failures | Redirects back with flash session errors | Responds with 422 Unprocessable Entity JSON |
| Success Output | HTML Document (return view()) or RedirectResponse |
JSON Payload (return response()->json()) |
| Primary Directory | resources/views/ is vital |
app/Http/Resources/ is vital |
You can see every single command available in your specific installation by typing php artisan list or simply php artisan in your terminal.
Because Laravel has over 100 built-in commands, printing them all out would create a massive wall of text. Instead, here is a categorized cheat sheet of the most essential and frequently used Artisan commands you will actually use day-to-day.
| Command | What it does |
php artisan serve |
Starts the local PHP development server (usually at localhost:8000). |
php artisan tinker |
Opens an interactive REPL shell to test database queries and PHP code on the fly. |
php artisan env |
Displays the current application environment (local, production, etc.). |
php artisan about |
Gives a comprehensive overview of your app configuration, drivers, and versions. |
make: Group (Code Scaffolding)Instead of creating files manually, use these commands to automatically generate boilerplate classes with proper namespaces in the correct directories.
| Command | What it does |
php artisan make:controller PostController |
Creates a regular Controller in app/Http/Controllers. |
php artisan make:controller PostController --api |
Creates an API controller with resource methods (minus create/edit). |
php artisan make:model Post |
Creates an Eloquent model in app/Models. |
php artisan make:model Post -mcr |
Pro Tip: Generates the Model, Database Migration, Resource Controller, and Factory all at once. |
php artisan make:migration create_posts_table |
Generates a structural database version-control schema file. |
php artisan make:seeder PostSeeder |
Creates a database seeder file. |
php artisan make:factory PostFactory |
Creates a fake data generation factory. |
php artisan make:middleware CheckAge |
Generates an HTTP request filtering middleware. |
php artisan make:resource PostResource |
Generates an API Resource transformer for data clean-up. |
migrate: & db:)| Command | What it does |
php artisan migrate |
Runs all pending database migrations to build or update your tables. |
php artisan migrate:rollback |
Reverts the last batch of database migrations. |
php artisan migrate:fresh |
Drops all tables completely and runs all migrations from scratch (destroys data). |
php artisan migrate:fresh --seed |
Wipes the database, rebuilds it, and populates it with your initial seed data. |
php artisan db:seed |
Runs the seeders to populate tables with mockup or default data. |
php artisan db:wipe |
Drops all tables, views, and types without re-running migrations. |
| Command | What it does |
php artisan route:list |
Displays a clear table of all registered routes, HTTP methods, and names. |
php artisan route:cache |
Caches your routes for lightning-fast parsing (use mostly in production). |
php artisan route:clear |
Deletes the compiled route cache file. |
php artisan config:cache |
Combines all config files into a single file for speed optimization. |
php artisan config:clear |
Clears the application configuration cache. |
php artisan optimize:clear |
Wipes caches for configuration, routes, views, and compiled classes all at once. |
| Command | What it does |
php artisan down |
Puts the app into maintenance mode (shows a "503 Service Unavailable" page to users). |
php artisan up |
Takes the app out of maintenance mode, making it live again. |
php artisan storage:link |
Creates a symbolic link from public/storage to storage/app/public so uploaded files are web-accessible. |
php artisan key:generate |
Sets the APP_KEY in your .env file to encrypt sessions and cookies securely. |
Pro Tip: If you ever forget how a command works or what arguments it accepts, just prefix it with
help. For example:php artisan help migrate:fresh.
To ensure you have absolutely everything at your fingertips, here is the literal, complete list of every single core command built into a standard Laravel installation.
They are organized alphabetically by their functional groups.
help — Displays help for a command.
list — Lists all available commands.
clear-compiled — Removes the compiled class file.
completion — Dump the shell completion script.
db — Start a CLI session with your database.
env — Display the current framework environment.
help — Display help for an Artisan command.
inspire — Display an inspiring quote.
optimize — Cache framework bootstrap files to maximize performance.
serve — Serve the application on the PHP development server.
tinker — Interact with your application inside a REPL shell.
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.
channel:channel:list — List all registered broadcast channels.
config:config:cache — Create a cache file for faster configuration loading.
config:clear — Remove the configuration cache file.
config:show — Display the current values of a configuration file.
db:db:monitor — Monitor the number of connections on the specified database.
db:seed — Seed the database with records.
db:show — Display information about the given database.
db:table — Display information about a specific database table.
db:wipe — Drop all tables, views, and types.
env:env:decrypt — Decrypt an environment file.
env:encrypt — Encrypt an environment file.
event:event:cache — Discover and cache the application's event listeners.
event:clear — Clear all cached events and listeners.
event:generate — Generate the missing events and listeners based on registration.
event:list — List the application's event listeners.
key:key:generate — Set the application key (APP_KEY in .env).
lang:lang:publish — Publish all language files to your project.
make: (The Generator Suite)make:cast — Create a new custom Eloquent cast class.
make:channel — Create a new broadcast channel class.
make:command — Create a new Artisan command.
make:component — Create a new Blade component.
make:controller — Create a new controller class.
make:enum — Create a new PHP enum structure.
make:event — Create a new event class.
make:exception — Create a new custom exception class.
make:factory — Create a new model factory.
make:interface — Create a new PHP interface file.
make:job — Create a new queued job class.
make:listener — Create a new event listener class.
make:mail — Create a new mailable class.
make:middleware — Create a new middleware class.
make:migration — Create a new database migration file.
make:model — Create a new Eloquent model class.
make:notification — Create a new notification class.
make:observer — Create a new model observer class.
make:policy — Create a new authorization policy class.
make:provider — Create a new service provider class.
make:request — Create a new form request class.
make:resource — Create a new API resource transformer.
make:rule — Create a new custom validation rule.
make:seeder — Create a new database seeder.
make:test — Create a new test class (Pest or PHPUnit).
make:trait — Create a new PHP trait.
migrate:migrate:fresh — Drop all tables and re-run all migrations.
migrate:install — Create the migration repository table inside the database.
migrate:refresh — Reset and re-run all migrations.
migrate:reset — Rollback all database migrations.
migrate:rollback — Rollback the last database migration operation.
migrate:status — Show the status of each migration (Run vs Pending).
model:model:prune — Prune models that are no longer needed.
model:show — Inspect an Eloquent model's attributes, types, and relations.
notifications:notifications:table — Create a migration for the notifications database table.
optimize:optimize:clear — Remove all framework cache files (Config, Route, View).
package:package:discover — Rebuild the cached package manifest list.
queue:queue:clear — Delete all jobs from a specified queue.
queue:failed — List all failed queue jobs.
queue:failed-table — Create a migration for the failed queue jobs database table.
queue:flush — Flush all failed queue jobs.
queue:forget — Delete a specific failed queue job.
queue:listen — Listen to a specified queue backend.
queue:monitor — Monitor the health and size of specified queues.
queue:prune-batches — Prune stale entries from the batch database table.
queue:prune-failed — Prune stale entries from the failed jobs database table.
queue:restart — Restart queue worker daemons after your current job finishes.
queue:retry — Retry a failed queue job.
queue:retry-batch — Retry the failed jobs for a specific batch.
queue:table — Create a migration for the queue jobs database table.
queue:work — Start processing jobs on the queue as a continuous daemon worker.
route:route:cache — Create a route cache file for lightning-fast execution.
route:clear — Remove the route cache file.
route:list — List all registered application routes.
schedule:schedule:clear-cache — Delete the background task schedule cache.
schedule:list — List all scheduled tasks / cron assignments.
schedule:run — Run the scheduled commands due for execution.
schedule:test — Run a mock test execution of your scheduled items.
schedule:work — Start the schedule worker daemon.
schema:schema:dump — Dump the current database schema structure into an SQL file.
session:session:table — Create a migration for the session database table.
storage:storage:link — Create a symbolic link from public/storage to storage/app/public.
stub:stub:publish — Publish all layout stubs to customize the code generated by make: commands.
vendor:vendor:publish — Publish any assets/configurations from installed vendor packages to your app root.
view:view:cache — Compile and cache all of your Blade views.
view:clear — Clear all compiled Blade view cache files.
Here is the absolute, complete directory of every core built-in Artisan command included in a standard installation.
clear-compiled — Remove the compiled class file to clear performance optimization tracking.
completion — Dump the shell autocomplete configuration script for Bash/Zsh.
db — Directly start a native CLI terminal session matching your .env configured database.
env — Display the active application environment configuration (e.g., local, production).
help — Show step-by-step documentation, arguments, and options allowed for a specific command.
inspire — Spit out a motivational quote from a classic philosopher or programmer.
list — Render a visual map layout of all commands registered to your application terminal.
optimize — Compile and cache framework bootstrap files (config, routes) to maximize request speeds.
serve — Launch Laravel's internal development server to review the site locally at http://127.0.0.1:8000.
test — Execute your framework test pipeline utilizing your configured testing engine (Pest or PHPUnit).
tinker — Open a dynamic Read-Eval-Print Loop (REPL) shell to test models and PHP evaluations live.
up — Bring the system out of maintenance mode, reopening web access to the public.
about: (Application Diagnostics)about — Display a clean diagnostic matrix outlining application versions, environment drivers, and caches.
auth: (Access Controls)auth:clear-resets — Purge expired password reset validation tokens directly out of the application database.
cache: (Temporary Memory Storage)cache:clear — Flush all saved key/value records entirely out of your application's default cache engine.
cache:forget — Manually delete one precise item by its unique configuration key name from your cache.
cache:table — Generate a standard database migration file to setup a dedicated database-backed cache table.
channel: (Event Broadcasting)channel:list — Generate a clean list overview detailing every broadcast websocket channel your app uses.
config: (Configuration Optimization)config:cache — Merge all independent .php files within config/* into one single fast-loading system cache.
config:clear — Erase your framework configuration cache file so changes update from files instantly.
config:show — Output all structured keys and current active values belonging to an isolated configuration file.
db: (Database Operations)db:monitor — Actively listen to and display current concurrent thread connection loads hitting your engine.
db:seed — Populate your database tables using instructions defined across your model seed files.
db:show — Output system insights highlighting open schemas, connection states, sizes, and metadata.
db:table — Drop a detailed visual matrix mapping properties, engine variants, columns, and rows of a target table.
db:wipe — Drop every table, view, structural constraint, and data type across your target database.
env: (Environment Variable Security)env:decrypt — Decrypt a securely encrypted production .env.encrypted backup back into readable plain text.
env:encrypt — Scramble an active .env file into a securely locked, ciphered document file for git safe-keeping.
event: (System Hooks & Observers)event:cache — Analyze the application codebase to map out and cache all active events to their listeners.
event:clear — Wipe clean the application's compiled event mapping performance file.
event:generate — Generate missing physical PHP files for Events or Listeners declared in your App code.
event:list — Output an explicitly organized dashboard tracking every active Event and the Listener structures tied to it.
install: (First-Time Service Scaffolding)install:api — Scaffolding installation steps to setup standard API structures, route assets, and Laravel Sanctum.
install:broadcasting — Scaffold real-time, bi-directional event setups and install essential channel configurations.
key: (Encryption Keys)key:generate — Generate a raw cryptographic string key and inject it straight to the APP_KEY line within your .env.
lang: (Multi-Language Localization)lang:publish — Export framework language directories to allow translation updates for default system messages.
make: (Scaffolding Automation Suite)make:cast — Create a new model property data type transformation cast block.
make:channel — Generate a targeted WebSockets broadcast authorization channel path wrapper.
make:class — Scaffold a fresh, cleanly namespaced PHP business logic class anywhere in your app folder.
make:command — Write code to setup your own unique, execution-ready custom php artisan terminal command.
make:component — Create a reusable Blade layout component architecture (generates template view + class).
make:controller — Build an HTTP routing processing layer controller.
make:enum — Construct a native strongly typed PHP back-backed Enumeration definition file.
make:event — Create a system event alert hook file.
make:exception — Establish custom, application-specific exception routing handlers.
make:factory — Set up a programmatic data generation blueprint module for database mocking.
make:interface — Generate a standard PHP contract Interface blueprint file.
make:job — Produce an individual background process logic block designed to handle heavy server executions.
make:listener — Create an event listener class designed to run logic when a specified system event fires.
make:mail — Build a custom transactional email construction object class.
make:middleware — Build an incoming HTTP filter layer block to evaluate web requests prior to core processing.
make:migration — Produce a structured database version-control blueprint file.
make:model — Initialize an explicit, object-relational mapping Eloquent model class to represent a database table.
make:notification — Initialize a multi-channel delivery notification block (Email, SMS, Slack, Database).
make:observer — Build a database event model state tracker designed to fire logic on records matching data changes.
make:policy — Scaffold an explicitly mapped object-level user authentication authorization rule block.
make:provider — Set up a Service Provider configuration block designed to bootstrap application container dependencies.
make:request — Create a dedicated custom form request script housing distinct authorization and validation logic.
make:resource — Build a transformation object layout designed to safely mask models when displaying public data API fields.
make:rule — Create a reusable complex custom validation logic evaluation checker.
make:seeder — Set up a database entry initialization file.
make:test — Build an individual feature or automated unit test code evaluation file.
make:trait — Initialize a native PHP structural trait pattern layout sheet.
migrate: (Schema State Management)migrate:fresh — Drop every single active table in the database and run all migrations from step one.
migrate:install — Build the core data tracking ledger database logging table used to follow system migrations.
migrate:refresh — Fully reverse every single executed historical database migration and instantly run them forward again.
migrate:reset — Execute a total destructive rollback reversal of every migration step ever tracked by the app database.
migrate:rollback — Rollback the operations executed in the single most recent migration batch iteration.
migrate:status — Display an organized status list mapping which migrations are applied vs outstanding.
model: (Eloquent Data Inspection)model:prune — Run routine checks against database model files to securely discard stale or unneeded tracking data rows.
model:show — Inspect a selected model class to see its exact attributes, field configurations, types, and active relationships.
notifications: (Alert System Setup)notifications:table — Generate a database migration to build a central system table for web notification tracking.
optimize: (Performance Trimming)optimize:clear — Clear compiled file optimizations across your settings configurations, routes, and layout caches.
package: (External Extension Core)package:discover — Dynamically crawl external dependencies to configure package auto-discover mapping paths.
queue: (Background Worker Process Pipelines)queue:clear — Purge every pending task record queued up across a selected active job processing tube.
queue:failed — Output a structured history detailing every background job that encountered exceptions and failed.
queue:failed-table — Build a migration table intended to hold metadata entries mapping job task execution failures.
queue:flush — Delete every single entry from the error-log table tracking failed background processes.
queue:forget — Target and erase one isolated failed background execution record via its unique reference ID.
queue:listen — Direct the execution terminal to stay awake and actively handle pipeline job requests as they come.
queue:monitor — Evaluate real-time system throughput levels, size, states, and active latency metrics across lines.
queue:prune-batches — Purge stale records out of the database logging tables tracking mass batch operations.
queue:prune-failed — Clean out expired logs tracking failed jobs from the data tracking tables.
queue:restart — Instruct all background queue processing threads to safely restart after finishing their active jobs.
queue:retry — Pick up a failed background task entry out of the logging tray and re-inject it back onto active queues.
queue:retry-batch — Re-queue a collective group batch set of operations that originally encountered errors.
queue:table — Build a standardized database ledger table configuration designed to back persistent job tracking queues.
queue:work — Launch a persistent system daemon loop tracking and processing tasks in real-time.
route: (URL Configuration Processing)route:cache — Build a highly efficient route cache layout to skip URL mapping processes on incoming requests.
route:clear — Delete your application route cache registry so newly registered URLs update immediately.
route:list — Render a comprehensive directory mapping every URI, method type, handler script, and active middleware block.
schedule: (Automated Cron Tasks)schedule:clear-cache — Force purge the lock token cache preventing overlapping cron schedules.
schedule:list — Display a clean task pipeline chart mapping out when every automated command is scheduled to fire.
schedule:run — Evaluate all defined app automated scripts and execute items actively due for operations.
schedule:test — Force trigger an intentional execution simulation test over all commands to debug configurations.
schedule:work — Start a persistent loop worker designed to tick every single minute to fire background automated tasks locally.
schema: (Raw Engine Blueprint Exports)schema:dump — Compile the active structure layout configuration of your database out into a single static SQL file.
session: (Persistent User Tracking)session:table — Scaffolds a database migration designed to write a dedicated session data persistence log table.
storage: (File Asset Linking)storage:link — Construct a native system symlink mapping from your private storage space to make media publicly accessible.
stub: (Boilerplate File Formats)stub:publish — Unpack and output default text template models used by make: commands so you can edit the generated layouts.
vendor: (Third-Party Dependency Operations)vendor:publish — Extract raw resource configurations, translations, and layout parameters from vendor packages to your app directories.
view: (Frontend UI Compilation)view:cache — Precompile your collection of Blade presentation templates into optimized PHP scripts for quick rendering.
view:clear — Clean out your application's compiled and cached front-end rendering file layouts.
To give you the absolute, unskipped full list with exact syntax and options, here is the complete directory of all 104 native Laravel Artisan commands structured into optimized tabular formats by their architectural modules.
| Command Syntax | Arguments / Options | Description |
|---|---|---|
php artisan clear-compiled |
None | Removes the compiled class file to clear optimization configurations. |
php artisan completion |
[shell] |
Dumps the shell auto-completion script for Bash, Zsh, or Fish. |
php artisan db |
[connection] |
Starts a native CLI terminal session matching your database driver configuration. |
php artisan env |
None | Displays the current application environment setting (local, production). |
php artisan help |
[command_name] |
Displays step-by-step documentation and options allowed for any command. |
php artisan inspire |
None | Outputs a motivational quote from a classic philosopher or programmer. |
php artisan list |
--raw, --format=json |
Renders a comprehensive visual directory mapping layout of all commands. |
php artisan optimize |
None | Compiles and caches framework bootstrap files to maximize request speeds. |
php artisan serve |
--host=, --port= |
Launches the local development server (defaults to http://127.0.0.1:8000). |
php artisan test |
--filter=, --coverage |
Executes your framework testing pipeline utilizing Pest or PHPUnit. |
php artisan tinker |
None | Opens an interactive REPL shell to test models and PHP evaluations live. |
php artisan up |
None | Brings the application out of maintenance mode, reopening public web access. |
| Command Syntax | Arguments / Options | Description |
|---|---|---|
php artisan about |
--json |
Displays a clean diagnostic matrix outlining versions, drivers, and caches. |
php artisan auth:clear-resets |
None | Purges expired password reset tokens directly out of the database. |
php artisan channel:list |
None | Generates a list overview detailing every broadcast websocket channel used. |
php artisan event:cache |
None | Analyzes code to discover, map, and cache application event listeners. |
php artisan event:clear |
None | Wipes clean the compiled event mapping performance file. |
php artisan event:generate |
None | Generates missing physical PHP files for Events or Listeners declared in code. |
php artisan event:list |
None | Outputs an organized dashboard tracking every active Event and its Listeners. |
php artisan key:generate |
--show |
Generates a cryptographic string and sets it to the APP_KEY in your .env. |
php artisan lang:publish |
None | Exports framework language directories to allow translation updates. |
| Command Syntax | Arguments / Options | Description |
|---|---|---|
php artisan cache:clear |
[tags] |
Flushes all saved records entirely out of the default cache engine. |
php artisan cache:forget |
[key] |
Manually deletes one precise item by its unique key name from the cache. |
php artisan cache:table |
None | Generates a standard database migration file to setup a database cache table. |
php artisan config:cache |
None | Merges all independent config files into one fast-loading system cache. |
php artisan config:clear |
None | Erases configuration cache files so changes update from files instantly. |
php artisan config:show |
[config_file] |
Outputs all structured keys and current values belonging to a configuration file. |
php artisan optimize:clear |
None | Clears compiled optimizations across settings, routes, and layout caches. |
db:)| Command Syntax | Arguments / Options | Description |
|---|---|---|
php artisan db:monitor |
--databases=, --max= |
Actively listens to and displays concurrent connection loads hitting engines. |
php artisan db:seed |
--class=, --force |
Populates database tables using instructions defined across seed files. |
php artisan db:show |
--counts, --views |
Outputs system insights highlighting open schemas, sizes, and metadata. |
php artisan db:table |
[table_name] |
Drops a visual matrix mapping properties and rows of a target table. |
php artisan db:wipe |
--database=, --force |
Drops every table, view, structural constraint, and type across the database. |
| Command Syntax | Arguments / Options | Description |
|---|---|---|
php artisan env:decrypt |
--key= |
Decrypts an encrypted production .env.encrypted backup file. |
php artisan env:encrypt |
--key= |
Scrambles an active .env file into a locked document for secure version control. |
php artisan install:api |
--without-migration |
Scaffolds API routing structures, routes file, and Laravel Sanctum token auth. |
php artisan install:broadcasting |
None | Scaffolds real-time event setups and essential channel configurations. |
make:)| Command Syntax | Options / Flags | Description |
|---|---|---|
php artisan make:cast [Name] |
None | Creates a new model property data type transformation cast block. |
php artisan make:channel [Name] |
None | Generates a targeted WebSockets broadcast authorization channel path wrapper. |
php artisan make:class [Name] |
None | Scaffolds a fresh, cleanly namespaced PHP business logic class. |
php artisan make:command [Name] |
--command= |
Writes code to setup your own unique, execution-ready Artisan command. |
php artisan make:component [Name] |
--view |
Creates a reusable Blade layout component (generates view + class). |
php artisan make:controller [Name] |
--api, --invokable, --resource |
Builds an HTTP request routing processing layer controller. |
php artisan make:enum [Name] |
None | Constructs a native strongly typed PHP backed Enumeration definition file. |
php artisan make:event [Name] |
None | Creates a system event alert hook file. |
php artisan make:exception [Name] |
None | Establishes custom, application-specific exception routing handlers. |
php artisan make:factory [Name] |
--model= |
Sets up a programmatic data generation blueprint module for database mocking. |
php artisan make:interface [Name] |
None | Generates a standard PHP contract Interface blueprint file. |
php artisan make:job [Name] |
--sync |
Produces an individual background process logic block for heavy tasks. |
php artisan make:listener [Name] |
--event= |
Creates an event listener class that runs logic when a specific event fires. |
php artisan make:mail [Name] |
--markdown= |
Builds a custom transactional email construction object class. |
php artisan make:middleware [Name] |
None | Builds an incoming HTTP filter layer block to evaluate web requests. |
php artisan make:migration [Name] |
--table=, --create= |
Produces a structured database version-control blueprint schema file. |
php artisan make:model [Name] |
-m, -c, -f, -s, -r, --all |
Initializes an object-relational mapping Eloquent model class. |
php artisan make:notification [Name] |
--markdown= |
Initializes a multi-channel delivery notification block (Email, SMS, Slack). |
php artisan make:observer [Name] |
--model= |
Builds a database event model state tracker for monitoring data changes. |
php artisan make:policy [Name] |
--model= |
Scaffold an object-level user authentication authorization rule block. |
php artisan make:provider [Name] |
None | Sets up a Service Provider configuration block to bootstrap dependencies. |
php artisan make:request [Name] |
None | Create custom form request scripts housing distinct validation logic. |
php artisan make:resource [Name] |
--collection |
Builds a transformation layer designed to safely mask internal model fields. |
php artisan make:rule [Name] |
--implicit |
Create a reusable complex custom validation logic evaluation checker. |
php artisan make:seeder [Name] |
None | Sets up a database entry initialization file. |
php artisan make:test [Name] |
--unit, --pest |
Builds an individual feature or automated unit test code evaluation file. |
php artisan make:trait [Name] |
None | Initialize a native PHP structural trait pattern layout sheet. |
| Command Syntax | Arguments / Options | Description |
|---|---|---|
php artisan migrate |
--database=, --force, --path= |
Runs all pending database migrations to build or update tables. |
php artisan migrate:fresh |
--seed, --drop-views |
Drops every single table in the database and runs all migrations from step one. |
php artisan migrate:install |
--database= |
Builds the core data tracking ledger database logging table for migrations. |
php artisan migrate:refresh |
--seed, --step= |
Fully reverses every executed migration and instantly runs them forward again. |
php artisan migrate:reset |
--database=, --force |
Executes a total rollback reversal of every migration step ever tracked. |
php artisan migrate:rollback |
--step=, --batch= |
Rollbacks operations executed in the single most recent migration batch. |
php artisan migrate:status |
None | Displays an organized status list mapping applied vs outstanding migrations. |
php artisan model:prune |
--model= |
Runs routine checks against database models to discard stale data rows. |
php artisan model:show |
[model_class] |
Inspects an Eloquent model to see attributes, types, and active relations. |
php artisan notifications:table |
None | Generates a database migration to build a central web notification tracking table. |
php artisan schema:dump |
--database=, --prune |
Compiles the active database layout structure into a single static SQL file. |
| Command Syntax | Arguments / Options | Description |
|---|---|---|
php artisan queue:clear |
[connection], --queue= |
Purges every pending task record queued up across a selected processing tube. |
php artisan queue:failed |
None | Outputs a structured history detailing background jobs that crashed. |
php artisan queue:failed-table |
None | Builds a migration table intended to hold metadata entries mapping failures. |
php artisan queue:flush |
[age] |
Deletes every single entry from the error-log table tracking failed processes. |
php artisan queue:forget |
[id] |
Targets and erases one isolated failed background execution record by its ID. |
php artisan queue:listen |
[connection], --timeout= |
Directs the terminal to stay awake and actively handle pipeline job requests. |
php artisan queue:monitor |
[queues], --max= |
Evaluates throughput levels, sizes, and active latency metrics across lines. |
php artisan queue:prune-batches |
--hours= |
Purges stale records out of database tables tracking mass batch operations. |
php artisan queue:prune-failed |
--hours= |
Clean out expired logs tracking failed jobs from data tracking tables. |
php artisan queue:restart |
None | Instructs background queue processing threads to safely restart after current jobs. |
php artisan queue:retry |
[id], all, redis |
Picks up a failed background task entry and re-injects it onto active queues. |
php artisan queue:retry-batch |
[batch_id] |
Re-queues a collective group batch set of operations that originally failed. |
php artisan queue:table |
None | Builds a standardized database ledger table configuration to back active queues. |
php artisan queue:work |
[connection], --once, --sleep= |
Launches a persistent system daemon loop tracking and processing jobs in real-time. |
| Command Syntax | Arguments / Options | Description |
|---|---|---|
php artisan route:cache |
None | Builds a routing cache layout to skip URL mapping processes on requests. |
php artisan route:clear |
None | Deletes the application route cache registry so newly registered URLs update. |
php artisan route:list |
--method=, --name=, --json |
Renders a comprehensive directory mapping every URI, method, and middleware. |
php artisan schedule:clear-cache |
None | Force purges the lock token cache preventing overlapping cron schedules. |
php artisan schedule:list |
None | Displays a clean task pipeline chart mapping when automated commands fire. |
php artisan schedule:run |
None | Evaluates defined automated scripts and executes items actively due. |
php artisan schedule:test |
--name= |
Force triggers an intentional execution simulation test over all commands. |
php artisan schedule:work |
None | Starts a local worker designed to tick every minute to run automated tasks. |
php artisan view:cache |
None | Precompiles your collection of Blade presentation templates into optimized PHP. |
php artisan view:clear |
None | Clears out the application's compiled and cached front-end layout files. |
| Command Syntax | Arguments / Options | Description |
|---|---|---|
php artisan package:discover |
None | Dynamically crawls external dependencies to configure auto-discover paths. |
php artisan session:table |
None | Scaffolds a database migration designed to write a dedicated session log table. |
php artisan storage:link |
None | Constructs a system symlink mapping from private storage to make media public. |
php artisan stub:publish |
None | Unpacks default text template models used by make: commands for customization. |
php artisan vendor:publish |
--provider=, --tag=, --force |
Extracts resource configurations and layouts from packages to app folders. |
If you install an authentication starter kit, these commands are added to handle frontend generation:
| Command Syntax | Arguments / Options | Description |
php artisan breeze:install |
[stack], --dark, --pest |
Installs the Breeze controllers, routes, and views into your project. |
php artisan jetstream:install |
[stack], --teams, --api |
Scaffolds the advanced Jetstream profile and team management engine. |
When setting up advanced API security layers, these packages add direct key-management utilities:
| Command Syntax | Arguments / Options | Description |
php artisan sanctum:prune-expired |
--hours= |
Deletes expired personal access tokens out of your database. |
php artisan passport:client |
--personal, --password |
Creates a new OAuth2 client endpoint for application authentication. |
php artisan passport:install |
--uuids, --force |
Creates the encryption keys and standard clients needed to run Passport. |
php artisan passport:keys |
--force |
Generates the secure cryptographic RSA keys for signing API tokens. |
php artisan passport:purge |
--hours= |
Purges revoked or completely expired tokens from your logs. |
Telescope is an elegant debug assistant for monitoring requests, exceptions, log entries, database queries, and queued jobs.
| Command Syntax | Arguments / Options | Description |
php artisan telescope:clear |
None | Completely flushes all recorded debug entries from Telescope's database. |
php artisan telescope:install |
None | Installs and scaffolds the Telescope configuration and public assets. |
php artisan telescope:pause |
None | Temporarily pauses Telescope from collecting system debug entries. |
php artisan telescope:prune |
--hours= |
Prunes stale debug entries older than a specified timeframe from the logs. |
php artisan telescope:publish |
None | Re-publishes the Telescope frontend JavaScript and CSS assets. |
php artisan telescope:resume |
None | Resumes data collection after a pause command has been issued. |
Horizon provides a beautiful dashboard and code-driven configuration for your Redis-backed queues.
| Command Syntax | Arguments / Options | Description |
php artisan horizon |
None | Starts the central Horizon master supervisor process loop. |
php artisan horizon:clear |
--queue= |
Clears all pending jobs completely out of the specified Horizon queues. |
php artisan horizon:forget |
[id] |
Manually deletes a targeted failed Horizon job using its unique ID. |
php artisan horizon:install |
None | Installs the Horizon configuration files and web assets into your project. |
php artisan horizon:pause |
None | Instructs the master supervisor process to pause processing any new queue jobs. |
php artisan horizon:publish |
None | Re-publishes Horizon’s frontend asset files to the public directory. |
php artisan horizon:purge |
None | Purges orphaned supervisor processes from the active Horizon runtime. |
php artisan horizon:status |
None | Outputs the current operational status of the Horizon master executioner. |
php artisan horizon:terminate |
None | Instructs the master supervisor to safely wind down and exit all active workers. |
Pulse provides at-a-glance insights into your application’s performance, usage metrics, and bottleneck areas.
| Command Syntax | Arguments / Options | Description |
php artisan pulse:check |
None | Launches the background recorder daemon to monitor system health. |
php artisan pulse:clear |
--type= |
Flushes all recorded performance data aggregates from the system database. |
php artisan pulse:install |
None | Scaffolds the native Pulse database migrations and configuration file. |
php artisan pulse:work |
None | Starts a persistent worker thread to process and aggregate recorded metrics. |
Cashier handles subscription billing services seamlessly through native database synchronization commands.
| Command Syntax | Arguments / Options | Description |
php artisan cashier:webhook |
--url=, --disabled |
Automatically creates and registers a Stripe webhook endpoint to your site. |
php artisan cashier:table |
None | Generates the essential database migrations required to track user subscriptions. |
Don't forget: you can add an unlimited number of commands yourself. When you run:
Bash
php artisan make:command RunCustomImport
Laravel will generate a new file in app/Console/Commands/. Inside that file, you define your own syntax name, like this:
PHP
protected $signature = 'app:run-custom-import {file} {--force}';
The moment you save that file, running php artisan will dynamically append php artisan app:run-custom-import right alongside all the system defaults!