ScriptsApr 12, 2026·1 min read

Laravel — The PHP Framework for Web Artisans

Laravel is an expressive, elegant PHP web framework. Provides routing, Eloquent ORM, Blade templates, queues, events, broadcasting, and a rich ecosystem (Forge, Vapor, Nova, Livewire). The most popular PHP framework by a wide margin.

SC
Script Depot · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

composer create-project laravel/laravel my-app
cd my-app
php artisan serve
# Visit http://localhost:8000
php artisan make:model Asset -mcr
# Creates: Model, Migration, Controller (resource)
// database/migrations/xxxx_create_assets_table.php
public function up(): void
{
    Schema::create("assets", function (Blueprint $table) {
        $table->id();
        $table->string("repo")->unique();
        $table->integer("stars")->default(0);
        $table->text("description")->nullable();
        $table->timestamps();
    });
}
// app/Models/Asset.php
class Asset extends Model
{
    protected $fillable = ["repo", "stars", "description"];
}
// routes/api.php
Route::get("/assets", function () {
    return Asset::orderByDesc("stars")->limit(10)->get();
});
php artisan migrate
php artisan tinker
> Asset::create(["repo" => "react", "stars" => 230000]);
Intro

Laravel is the most popular PHP framework, created by Taylor Otwell in 2011. Its philosophy: web development should be an enjoyable, creative experience. Laravel provides an expressive, elegant syntax with a comprehensive ecosystem: Eloquent ORM, Blade templates, queues, events, broadcasting, Forge (server management), Vapor (serverless), and Livewire (reactive UI without JS).

What Laravel Does

  • Routing — expressive route definitions
  • Eloquent ORM — ActiveRecord pattern, relationships, scopes
  • Blade templates — lightweight, compiled template engine
  • Artisan CLI — code generation, migrations, tinker REPL
  • Queues — Redis, SQS, database queue drivers
  • Events and broadcasting — event-driven + WebSocket (Reverb)
  • Auth — sessions, API tokens (Sanctum), OAuth (Passport)
  • Livewire — reactive frontend components in PHP
  • Testing — PHPUnit + Pest integration
  • Inertia.js — SPA without building an API

Architecture

MVC: Models (Eloquent), Views (Blade), Controllers. Service container provides IoC/DI. Facades wrap services for static-like syntax. Middleware pipeline for request/response processing. SOLID principles and PSR standards throughout.

Self-Hosting

# Production on Linux + Nginx
composer install --optimize-autoloader --no-dev
php artisan config:cache
php artisan route:cache
php artisan view:cache

Or use Laravel Forge (automated server provisioning) or Vapor (serverless on AWS Lambda).

Key Features

  • Eloquent ORM
  • Blade templates
  • Artisan CLI
  • Queue system
  • Broadcasting (Reverb WebSocket)
  • Sanctum API auth
  • Livewire for reactive UI
  • Inertia.js for modern SPAs
  • Pest testing framework
  • Laravel Forge and Vapor ecosystem

Comparison

Framework Language Style Ecosystem
Laravel PHP Elegant, batteries Largest PHP
Symfony PHP Components, enterprise Large
Django Python Batteries-included Large
Rails Ruby Convention > config Large
NestJS TypeScript Angular-inspired Large
Spring Boot Java Enterprise Largest Java

常见问题 FAQ

Q: Laravel vs Symfony? A: Laravel 更 opinionated、开发速度快、DX 好;Symfony 更 modular、企业级、可重用组件(实际上 Laravel 底层用了很多 Symfony 组件)。

Q: Livewire 替代 React? A: 对中等交互性的应用可以。Livewire 用 PHP 写响应式 UI,省去前后端分离。超复杂交互仍然建议 React/Vue + Inertia。

Q: 性能问题? A: PHP 8.3 + OPcache + Route/Config cache + Octane (Swoole/Franken) 后性能不输 Node.js。

来源与致谢 Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets