Laravel provides a complete ecosystem for web artisans. Our open source PHP framework, products, packages, and starter kits offer everything you need to build, deploy, and monitor web applications.
Watch video 2 mins
Trusted by thousands of companies around the world
Out of the box, Laravel has elegant solutions for the common features needed by all modern web applications. Our first-party packages offer opinionated solutions for specific problems so you don't need to reinvent the wheel.
Simple, elegant syntax powers amazing functionality. Every feature has been considered to create a thoughtful and cohesive development experience.
1Add an authentication middleware to your Laravel route
1Route::get('/profile', ProfileController::class)2 ->middleware('auth');
2You can access the authenticated user via the Auth facade
1use Illuminate\Support\Facades\Auth;2 3$user = Auth::user();
1Define a policy for your model
1public function update(User $user, Post $post): Response2{3 return $user->id === $post->user_id4 ? Response::allow()5 : Response::deny('You do not own this post.');6}
2Use the policy via the Gate facade
1Gate::authorize('update', $post);
1Define a model for your database table
1<?php 2 3namespace App\Models; 4 5use Illuminate\Database\Eloquent\Model; 6 7class Flight extends Model 8{ 9 // ...10}
2Use Eloquent to retrieve records from the database
1use App\Models\Flight;2 3foreach (Flight::all() as $flight) {4 echo $flight->name;5}
1Create a migration for your database table
1php artisan make:migration create_posts_table --create=posts
2Define the schema in your migration file
1class CreatePostsTable extends Migration 2{ 3 public function up() 4 { 5 Schema::create('posts', function (Blueprint $table) { 6 $table->id(); 7 $table->string('title'); 8 $table->text('content'); 9 $table->foreignId('user_id')->constrained()->onDelete('cascade');10 $table->timestamps();11 });12 }13}
1Define validation rules in your controller
1public function store(Request $request)2{3 $validated = $request->validate([4 'title' => 'required|max:255',5 'content' => 'required',6 'email' => 'required|email',7 ]);8}
2Handle validation errors in your view
1@if ($errors->any())2 <div class="alert alert-danger">3 <ul>4 @foreach ($errors->all() as $error)5 <li>{{ $error }}</li>6 @endforeach7 </ul>8 </div>9@endif
1Define the notification content
1class PostCreated extends Notification 2{ 3 public function via() 4 { 5 return ['mail', 'database']; // Send via mail and store in database 6 } 7 8 public function toMail($notifiable) 9 {10 return (new MailMessage)11 ->subject('New Post Created')12 ->line('A new post has been created: ' . $this->post->title)13 ->action('View Post', url('/posts/' . $this->post->id))14 ->line('Thank you for using our application!');15 }16}
2Send the notification to the user
1public function store(Request $request)2{3 $post = Post::create($request->all());4 5 $request->user()->notify(new PostCreated($post));6}
1Configure your filesystem
1FILESYSTEM_DRIVER=s3
2Handle file uploads in your controller
1public function store(Request $request)2{3 if ($request->hasFile('image')) {4 $path = $request->file('image')->store('images', 'public');5 }6}
1Define the job logic
1class ProcessPost implements ShouldQueue2{3 public function handle()4 {5 $this->post->update([6 'rendered_content' => Str::markdown($this->post->content)7 ]);8 }9}
2Dispatch the job from your controller
1public function store(Request $request)2{3 $post = Post::create($request->all());4 5 ProcessPost::dispatch($post);6}
1Define the command logic
1class SendEmails extends Command 2{ 3 protected $signature = 'emails:send'; 4 5 protected $description = 'Send scheduled emails'; 6 7 public function handle() 8 { 9 // Send your emails...10 }11}
2Schedule the task
1Schedule::command('emails:send')->daily();
1Write your test using Pest
1it('can create a post', function () { 2 $response = $this->post('/posts', [ 3 'title' => 'Test Post', 4 'content' => 'This is a test post content.', 5 ]); 6 7 $response->assertStatus(302); 8 9 $this->assertDatabaseHas('posts', [10 'title' => 'Test Post',11 ]);12});
2Run the tests on the command line
1php artisan test
1Create your event
1class PostCreated implements ShouldBroadcast 2{ 3 use Dispatchable, SerializesModels; 4 5 public $post; 6 7 public function __construct(Post $post) 8 { 9 $this->post = $post;10 }11}
2Dispatch the event in your controller
1public function store(Request $request)2{3 $post = Post::create($request->all());4 5 PostCreated::dispatch($post);6}
3In your JavaScript file, listen for the event
1Echo.channel("posts." + postId).listen("PostCreated", (e) => {2 console.log("Post created:", e.post);3});
Whether you prefer a traditional PHP backend, a modern frontend using Laravel Livewire, or can't get enough React and Vue, Laravel allows you to deliver highly polished and maintainable applications in a fraction of the time.
1class UserController 2{ 3 public function index() 4 { 5 $users = User::active() 6 ->orderByName() 7 ->get(['id', 'name', 'email']); 8 9 return Inertia::render('Users', [10 'users' => $users,11 ]);12 }13}
1export default ({ users }) => { 2 return ( 3 <div> 4 <h1>Users</h1> 5 <ul> 6 {users.map((user) => ( 7 <li key={user.id}>{user.name}</li> 8 ))} 9 </ul>10 </div>11 );12};
Laravel Inertia supercharges your Laravel experience and works seamlessly with React, Vue, and Svelte. Inertia handles routing and transferring data between your backend and frontend, with no need to build an API or maintain two sets of routes.
1class Counter extends Component 2{ 3 public $count = 1; 4 5 public function increment() 6 { 7 $this->count++; 8 } 9 10 public function decrement()11 {12 $this->count--;13 }14 15 public function render()16 {17 return view('livewire.counter');18 }19}
1<div>2 <h1>{{ $count }}</h1>3 4 <button wire:click="increment">+</button>5 6 <button wire:click="decrement">-</button>7</div>
Laravel Livewire transforms your Laravel applications by bringing dynamic, reactive interfaces directly to your Blade templates. Livewire seamlessly bridges the gap between server-side rendering and client-side interactivity, allowing you to create modern, interactive components without leaving the comfort of Laravel.
1Route::get('/api/user', function (Request $request) {2 return $request->user();3})->middleware('auth:sanctum');
Laravel empowers developers to build robust backends for single-page applications (SPAs) and mobile apps with ease and efficiency. With built-in support for RESTful APIs, authentication, and database management, Laravel simplifies the process of connecting your backend to modern frontend frameworks like Vue.js or React.
Laravel Cloud provides a fully managed application platform for Laravel applications, while Forge allows you to self-manage VPS servers running Laravel applications.
A fully managed application platform built for developers and teams who just want to ship their next big idea.
Plans from $0.00 / month
Provision VPS servers and deploy unlimited PHP applications on DigitalOcean, Akamai, Vultr, Amazon, Hetzner, and more.
Plans from $12.00 / month
Every Laravel application can achieve enterprise-grade quality with monitoring, observability, and testing tools that empower you to ship with confidence.
Monitoring built for Laravel developers and teams that need to know exactly what's happening in their application.
Pricing coming soon
At-a-glance insights into your application's performance and usage. Track down bottlenecks like slow jobs and endpoints, find your most active users, and more.
Free
An elegant debug assistant providing insight into the requests coming into your application, exceptions, log entries, database queries, queued jobs, and more.
Free
Pest is a testing framework with a focus on simplicity, meticulously designed to bring back the joy of testing in PHP.
Free
Join thousands of developers and companies around the world.
“I've been using Laravel for nearly a decade and have never been tempted to switch to anything else.”
“Laravel is our sourdough starter and multitool for web projects large and small. 10 years in, it remains fresh and useful.”
“Laravel takes the pain out of building modern, scalable web apps.”
“Laravel grew to be an amazing and active community. Laravel is so much more than just a PHP framework.”
“Shipping apps with Laravel means balancing performance, flexibility, and simplicity—while ensuring a great developer experience.”
“Laravel is a breath of fresh air in the PHP ecosystem, with a brilliant community around it.”
“The framework, the ecosystem and the community - it's the perfect package.”
“AI development moves fast. With Laravel, shipping AI-powered applications has never been easier.”
“With Laravel we can build our clients scalable, performant web apps and APIs in months that would otherwise take years.”
“Laravel's best-in-class testing tools give me the peace of mind to ship robust apps quickly.”
“Laravel has made it very simple to create services that handle hundreds of millions of requests and billions of background per day.”
“Laravel has helped me launch products quicker than any other solution, allowing me to get to market faster as the community has evolved.”
“Laravel has been like rocket fuel for my career and business.”
“I've been using Laravel for every project over the past ten years, to this date, there's just nothing like it.”
“I've been using Laravel for over 10 years and I can't imagine using PHP without it.”
“Laravel is for developers who write code because they can rather than because they have to.”
“I've been enjoying Laravel's focus on pushing DX to the next level for many years. It is well-designed and has stellar documentation.”
“The Laravel ecosystem has been integral to the success of our business. The framework allows us to move fast and ship regularly.”
“Laravel is nothing short of a delight. It allows me to build any web-y thing I want in record speed with joy.”
“I didn't fully appreciate Laravel's one-stop-shop solution until I tried (many) different ecosystems. Laravel is in a class of its own!”
Get started now and ship something amazing.
Laravel is the most productive way to
build, deploy, and monitor software.