Laravel is an intensely productive full-stack web framework. Pair Laravel and its rich ecosystem with Livewire, React, or Vue to build your next big idea and ship faster than you ever thought possible.
Laravel is an intensely productive full-stack web framework. Pair Laravel and its rich ecosystem with Livewire, React, or Vue to build your next big idea and ship faster than you ever thought possible.
Out of the box, Laravel has elegant solutions for the common features needed by all modern web applications. It's time to start building amazing applications and stop wasting time searching for packages and reinventing the wheel.
Authenticating users is as simple as adding an authentication middleware to your Laravel route definition:
Route::get('/profile', ProfileController::class) ->middleware('auth');
Once the user is authenticated, you can access the authenticated user via the Auth
facade:
use Illuminate\Support\Facades\Auth; // Get the currently authenticated user...$user = Auth::user();
Of course, you may define your own authentication middleware, allowing you to customize the authentication process.
For more information on Laravel's authentication features, check out the authentication documentation.
You'll often need to check whether an authenticated user is authorized to perform a specific action. Laravel's model policies make it a breeze:
php artisan make:policy UserPolicy
Once you've defined your authorization rules in the generated policy class, you can authorize the user's request in your controller methods:
public function update(Request $request, Invoice $invoice){ Gate::authorize('update', $invoice); $invoice->update(/* ... */);}
Scared of databases? Don't be. Laravel’s Eloquent ORM makes it painless to interact with your application's data, and models, migrations, and relationships can be quickly scaffolded:
php artisan make:model Invoice --migration
Once you've defined your model structure and relationships, you can interact with your database using Eloquent's powerful, expressive syntax:
// Create a related model...$user->invoices()->create(['amount' => 100]); // Update a model...$invoice->update(['amount' => 200]); // Retrieve models...$invoices = Invoice::unpaid()->where('amount', '>=', 100)->get(); // Rich API for model interactions...$invoices->each->pay();
Migrations are like version control for your database, allowing your team to define and share your application's database schema definition:
public function up(): void{ Schema::create('flights', function (Blueprint $table) { $table->uuid()->primary(); $table->foreignUuid('airline_id')->constrained(); $table->string('name'); $table->timestamps(); });}
Laravel has over 90 powerful, built-in validation rules and, using Laravel Precognition, can provide live validation on your frontend:
public function update(Request $request){ $validated = $request->validate([ 'email' => 'required|email|unique:users', 'password' => Password::required()->min(8)->uncompromised(), ]); $request->user()->update($validated);}
Use Laravel to quickly send beautifully styled notifications to your users via email, Slack, SMS, in-app, and more:
php artisan make:notification InvoicePaid
Once you have generated a notification, you can easily send the message to one of your application's users:
$user->notify(new InvoicePaid($invoice));
Laravel provides a robust filesystem abstraction layer, providing a single, unified API for interacting with local filesystems and cloud based filesystems like Amazon S3:
$path = $request->file('avatar')->store('s3');
Regardless of where your files are stored, interact with them using Laravel's simple, elegant syntax:
$content = Storage::get('photo.jpg'); Storage::put('photo.jpg', $content);
Laravel lets you to offload slow jobs to a background queue, keeping your web requests snappy:
$podcast = Podcast::create(/* ... */); ProcessPodcast::dispatch($podcast)->onQueue('podcasts');
You can run as many queue workers as you need to handle your workload:
php artisan queue:work redis --queue=podcasts
For more visibility and control over your queues, Laravel Horizon provides a beautiful dashboard and code-driven configuration for your Laravel-powered Redis queues.
Learn more
Schedule recurring jobs and commands with an expressive syntax and say goodbye to complicated configuration files:
$schedule->job(NotifySubscribers::class)->hourly();
Laravel's scheduler can even handle multiple servers and offers built-in overlap prevention:
$schedule->job(NotifySubscribers::class) ->dailyAt('9:00') ->onOneServer() ->withoutOverlapping();
Laravel is built for testing. From unit tests to browser tests, you’ll feel more confident in deploying your application:
$user = User::factory()->create(); $this->browse(fn (Browser $browser) => $browser ->visit('/login') ->type('email', $user->email) ->type('password', 'password') ->press('Login') ->assertPathIs('/home') ->assertSee("Welcome {$user->name}"));
Laravel's events allow you to send and listen for events across your application, and listeners can easily be dispatched to a background queue:
OrderShipped::dispatch($order);
class SendShipmentNotification implements ShouldQueue{ public function handle(OrderShipped $event): void { // ... }}
Your frontend application can even subscribe to your Laravel events using Laravel Echo and WebSockets, allowing you to build real-time, dynamic applications:
Echo.private(`orders.${orderId}`) .listen('OrderShipped', (e) => { console.log(e.order); });
We've just scratched the surface. Laravel has you covered for everything you will need to build a web application, including email verification, rate limiting, and custom console commands. Check out the Laravel documentation to keep learning or get started right away with our Laravel bootcamp.
There are dozens of ways to build your application's frontend. Thankfully, your options are wide open with Laravel. 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.
Supercharge Laravel with React, Vue, or Svelte
Reactive server-rendered templates with PHP
Build powerful APIs faster than ever
Laravel Inertia handles routing and transferring data between your Laravel back-end and frontend — no need to build an API or maintain two sets of routes. Pass data effortlessly from your database directly to the props of your frontend page components with all of the features of Laravel at your fingertips in one fantastic monorepo
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}
1import Layout from './Layout' 2 3export default function Users({ users }) { 4 return ( 5 <Layout> 6 {users.map(user => ( 7 <Link href={route('users.show', user)}> 8 {user.name} ({user.email}) 9 </Link>10 ))}11 </Layout>12 )13}
Inertia gives you the developer experience and simplicity of creating a server-rendered, multi-page application with the user experience and responsiveness of a JavaScript SPA.
Your frontend components can focus on user interactions instead of API calls and data manipulation — no more manually triggering HTTP requests and juggling responses.
Inertia even offers server-side rendering on initial page loads for applications that benefit from search engine optimization.
Your application's initial page load will return an Inertia-powered SPA and page props in a single request. Subsequent requests from clicking links or submitting forms will automatically return only the page props that are needed.
When you deploy new assets, Inertia will automatically perform the next request as a full page load, so your users will have the latest assets without missing a beat.
Livewire is a modern way to build dynamic interfaces using server-rendered templates instead of a JavaScript framework. It combines the simplicity and speed of building a server-rendered application with the user experience of a JavaScript SPA. You have to see it to believe it.
1use Livewire\Component; 2 3class Search extends Component 4{ 5 public $search = ''; 6 7 public function render() 8 { 9 $users = User::search($this->search)->get();10 11 return view('livewire.search', [12 'users' => $users,13 ]);14 }15}
1<div> 2 <input wire:model="search" 3 type="text" 4 placeholder="Search users..." /> 5 6 <ul> 7 @foreach ($users as $user) 8 <li>{{ $user->username }}</li> 9 @endforeach10 </ul>11</div>
When using Livewire, you won't need JavaScript to manage the DOM or state - you'll just sprinkle it in for some thoughtful interactions. Alpine.js is the perfect light-weight JavaScript library to pair with your Livewire application.
As the state of your Livewire component changes, your frontend will automatically be updated. But, Livewire doesn't stop there. Support for real-time validation, event handling, file downloads, authorization and more is included.
Livewire renders your HTML on the server using the Blade templating language. It automatically adds the JavaScript required to make the page reactive, and automatically re-renders components and updates the DOM as data changes.
Don't need a frontend? No problem. Laravel is the perfect back-end API for your JavaScript SPAs and mobile applications. You'll have access to all of Laravel's features while maintaining the frontend development workflow you're used to.
1class UserController2{3 public function index()4 {5 return User::active()6 ->orderByName()7 ->paginate(25, ['id', 'name', 'email']);8 }9}
1{ 2 "data": [ 3 { 4 "id": 1, 5 "name": "Taylor Otwell", 7 }, 8 // ... 9 ],10 "from": 1,11 "to": 25,12 "total": 50,13 "per_page": 25,14 "current_page": 1,15 "last_page": 2,16 "first_page_url": "https://api.laravel.app/users?page=1",17 "last_page_url": "https://api.laravel.app/users?page=2",18 "next_page_url": "https://api.laravel.app/users?page=2",19 "prev_page_url": null,20 "path": "https://api.laravel.app/users",21}
For authentication, you may leverage Laravel's secure, cookie-based authentication. Or, you may use Laravel Sanctum or Laravel Passport if you're building a mobile application or your frontend is hosted separately from your back-end API.
If your API operates at extreme scale, pair your Laravel application with Laravel Octane and Laravel Vapor to handle your traffic without breaking a sweat.
Whether you prefer Livewire or React, Laravel's starter kits let you hit the ground running. In minutes, you can have a fully functioning application that pairs Laravel and Tailwind with the frontend of your choice.
Laravel Breeze is a light-weight starter kit that includes Tailwind styled authentication user profile management templates.
Laravel Jetstream is a powerful starter kit with authentication views, user profile management, team management, and much more.
Laravel's biggest strength is its passionate community and ecosystem. Enjoy conferences held around the globe or stop by your local meetup. Learn from Laracasts, our dedicated course platform, and enjoy a plethora of packages and tutorials.