What Is New in Laravel 12.0
| Category | Key Changes |
|---|---|
| New Features | Laravel Reverb, Model::preventAccessingMissingAttributes() |
| Developer Experience | New Artisan commands, String password helper |
| Database & Eloquent | MariaDB driver, Can() and Cannot() methods, Atomic Locks table |
| Deprecations | Removed deprecated code from Laravel 11 |
What's the big deal with Laravel Reverb?
Laravel 12 introduces Reverb, a first-party WebSocket server for real-time applications. This is a game-changer because it's built specifically for Laravel and integrates seamlessly with Laravel's existing broadcasting capabilities. You get blazing-fast performance with support for HTTP/2 and server-side events, all without needing third-party PHP extensions.
In practice, this means you can handle WebSocket connections directly within your Laravel ecosystem. It simplifies your deployment stack since you're not configuring separate Pusher or Socket.io servers. The integration with Laravel Forge and Vapor makes deployment straightforward for most projects.
How does the new attribute access control work?
Eloquent now includes stricter attribute handling with Model::preventAccessingMissingAttributes(). This throws an exception when you try to access model attributes that weren't retrieved or don't exist, replacing the previous silent null returns.
This matters because it catches bugs early in development. You'll immediately know if you're trying to use a database column that wasn't included in your select statement or doesn't exist on the model. It makes your code more predictable and prevents those hard-to-find issues where you're accessing undefined properties.
You can enable this globally in your application's service provider or use it selectively during development. The control gives you flexibility while maintaining backward compatibility for existing applications.
What database improvements should I know about?
The MariaDB driver now has first-class support with proper version detection and compatibility handling. This means Laravel automatically adjusts its behavior based on whether you're using MySQL or MariaDB, so you don't have to worry about underlying database differences.
For permissions, the new can() and cannot() methods provide a cleaner syntax for authorization checks within your Blade templates. Instead of wrapping checks in @if statements, you can use <div can="create,App\Models\Post"> for more readable authorization logic in your views.
Atomic locks also got smarter with a dedicated database table driver. This is useful when you're running multiple application servers and need distributed lock management without relying on Redis or Memcached.
What new developer tools are included?
Laravel 12 adds several Artisan commands that streamline common tasks. The make:class command creates simple PHP classes, while make:enum sets up enum structures. There's also model:show which displays information about a model including its attributes, relationships, and methods.
The new Str::password method generates secure random passwords, eliminating the need for external password generation packages. These tools follow Laravel's philosophy of giving developers quick, built-in solutions for everyday development needs.
What was removed or deprecated?
Laravel 12 completes the removal of functionality that was previously deprecated in Laravel 11. This includes old exception handling methods, deprecated string helpers, and legacy authentication features that were marked for removal.
This cleanup keeps the framework lean and maintainable. If you're upgrading from an older version, you'll want to check the upgrade guide for specific changes that might affect your application. The removed features were all properly deprecated, so you should have received advance warning if you were using them.
FAQ
Do I need to use Laravel Reverb for real-time features?
No, Reverb is optional. You can still use Pusher, Ably, or other Laravel-supported broadcasting drivers. Reverb just gives you a first-party alternative that's optimized for Laravel applications.
Will the strict model attribute access break my existing application?
It might if your code accesses missing attributes. The feature is disabled by default, so you can enable it when you're ready to audit your code. Start by enabling it in development to identify any issues before production deployment.
Can I use the new MariaDB support with existing MySQL databases?
Yes, the driver automatically detects which database you're using and adjusts accordingly. You don't need to change your configuration if you switch between MySQL and MariaDB.
What's the advantage of the new can() method in Blade?
It makes your templates cleaner by replacing @if(auth()->user()->can('create', App\Models\Post)) with the more concise <div can="create,App\Models\Post">. It's purely syntactic sugar but improves readability.
Are the new Artisan commands replacing existing ones?
No, they're additions to the existing command suite. The make:class and make:enum commands complement rather than replace the familiar make:model or make:controller commands.