What's New in Laravel 11
Another year, another major Laravel version! Laravel 11 doubles down on simplicity and productivity, focusing on getting you up and running as quickly as possible. Let's take a quick look at the stand-out features that you absolutely should be aware of.
Progress
Series Info
- Episodes
- 14
- Run Time
- 51m
- Difficulty
- Intermediate
- Last Updated
- Mar 12, 2024
- Version
- Latest
Series Episodes
- Changes for New Projects (5)
Fewer Config Files
You don't have to change anything in your skeleton to upgrade to Laravel 11. However, the first thing you'll likely notice when creating a new Laravel 11 project is the lack of... files! For example, a number of config files have been removed out of the box. How will this affect you? Let's take a look.Missing Middleware
You might be surprised to find that new Laravel 11 projects ship with an emptyapp/Http/Middlewaredirectory. All of those files now live in the framework. Let's take a look at how you can configure them should you need to, as well as how to create and register your own middleware.Streamlined Scheduling
With allKernelclasses removed in Laravel 11, how do we schedule background tasks? It’s super simple, thanks to a shiny newSchedulefacade.Installing an API
If you look in theroutesdirectory, you’ll notice that there are a couple of files missing, includingapi.php. Don’t panic, when you need an API for your app, it’s just an Artisan command away.Sqlite Out of the Box
Here's a little change that I think explains the entire ethos behind the skeleton changes found in Laravel 11 - SQLite is now configured out of the box.
- Changes for All Projects (9)
The Dumpable Trait
A number of classes in Laravel havedumpandddmethods available for quick debugging. With Laravel 11, it’s a breeze to add the same functionality to your own classes.Limitless Limits for Eager Loading
Limiting the number of records on an eager loaded relationship in Laravel has historically been a pain, with a number of unexpected side effects. In Laravel 11, we can finally lay that issue to rest, because it now works exactly as you’d expect.Super Simple Memoization
We all have different methods for memoization - the technique of caching an expensive operation for the lifecycle of a request. In Laravel 11, we can memoize any value with a single, simple function calledonce.A Minor Tweak to Model Casts
All Laravel developers are familiar with the$castsproperty. That property will still work in Laravel 11, but the new default is acastsmethod instead. What's the reason for the change? Let me quickly demonstrate!Per Second Rate Limits
Have you had chance to use Laravel's rate limiter? It's pretty powerful. However, it's historically only been able to limit requests by the minute. Laravel 11 allows you to go further with per-second rate limiting, allowing for even more fine-grained control.Retrying Asynchronous Requests
Laravel allows us to make concurrent requests to external APIs using the handyHttp::poolmethod. However, you may have noticed that certain options, like retrying failed requests, aren't supported… until now.Encryption Key Rotation
Occasionally rotating your application's encryption key is considered a good security practice, but it terminates user sessions and can even cause exceptions when old data is encountered! Thankfully, Laravel 11 allows us to keep a list of previous keys that it will check against when decrypting.No Need for Flags
Whilst Laravel has supported both PHPUnit and Pest PHP as testing frameworks for a while now, Pest has always felt a little like a second class citizen. Laravel is now able to determine which test framework you're using, so you never have to remember to use that--pestflag.Simple Tests for Complex Jobs
Have you ever wanted to test that a job has been marked as deleted, failed or released? Doing so has been a bit of hack in previous Laravel versions. A shinywithFakeQueueInteractionsmethod makes that frustration a thing of the past. For our final episode, let's look at an example.
