Laravel
- Pronunciation
- LAR-uh-vel
In short
Laravel is a PHP framework for full web applications, with an elegant syntax and built-in routing, the Eloquent ORM, authentication, queues and migrations.
What is Laravel?
Laravel was created by Taylor Otwell and first released in 2011, and it has since become the most popular PHP framework. It follows the MVC pattern: routes send requests to controllers, Eloquent models represent database tables, and Blade templates render the HTML. Much of the everyday work, from validation to sending email, is a short, readable method call.
Eloquent is an active record ORM: a Post model maps to a posts table, and Post::where('published', true)->latest()->get() reads like a sentence. Migrations keep the database schema in version-controlled code, and the Artisan command line generates files, runs migrations, starts queue workers and schedules tasks.
Around the framework is an ecosystem of official tools: Breeze and Jetstream for login and registration scaffolding, Sanctum for API tokens, Horizon for queue monitoring, Livewire for interactive pages without much JavaScript, and Forge and Vapor for deployment. That completeness is a big reason teams choose it for SaaS products and business applications.
A common misconception is that PHP, and therefore Laravel, is outdated. Modern PHP is fast and typed, and Laravel offers features comparable to Rails or Django. Like them, it rewards following its conventions; fighting them usually makes a Laravel app harder to maintain.
Key takeaways
- Laravel is the most popular PHP framework, first released in 2011.
- It uses MVC with routes, controllers, Eloquent models and Blade views.
- Eloquent is an expressive active record ORM; migrations version the schema.
- Artisan, queues, scheduling and auth scaffolding come built in.
- Official tools such as Sanctum, Horizon and Livewire extend it.
Example
<?php
// routes/web.php
use App\Models\Post;
use Illuminate\Support\Facades\Route;
Route::get('/posts', function () {
$posts = Post::where('published', true)
->latest()
->take(10)
->get();
return view('posts.index', ['posts' => $posts]); // resources/views/posts/index.blade.php
});
// app/Models/Post.php
class Post extends \Illuminate\Database\Eloquent\Model
{
protected $fillable = ['title', 'body', 'published'];
}
// php artisan make:model Post --migration generates the model and a migrationReaders ask
Is Laravel a frontend or backend framework?
Backend. Laravel runs on the server in PHP. It can render HTML with Blade, or act as an API for a front end built with Vue, React or Inertia.
What is Eloquent?
Laravel's ORM. Each model class represents a database table, and you query and save records with PHP methods instead of writing SQL by hand.
Laravel or Symfony?
Both are mature PHP frameworks. Laravel focuses on developer convenience and an all-in-one ecosystem; Symfony offers reusable components and is often chosen for large, highly customized systems. Laravel itself uses several Symfony components.
See also
- PHPProgramming Languages, p. 23PHP is a dynamically typed scripting language designed for web development that runs on the server to generate HTML pages and respond to browser requests.
- MVCSoftware Architecture, p. 29MVC is an architectural pattern that splits an application into a Model for data and logic, a View for display, and a Controller that handles user input.
- ORMDatabases, p. 33An ORM is a library that maps database tables to objects in your programming language, letting you read and write data with code instead of raw SQL.
- Database MigrationDatabases, p. 8A database migration is a versioned script that changes a database's schema, such as adding a column, so every environment applies the same changes in order.
- REST APIBackend & APIs, p. 38A REST API is a web API that exposes data as resources identified by URLs and lets clients read or change them using standard HTTP methods.
- Background JobBackend & APIs, p. 6A background job is a task that a server runs outside the normal request-response cycle, so slow work like sending emails doesn't make users wait.
Spotted a mistake or something missing on this page?Suggest an edit