Key Features and Upgrades in Laravel 11.26 and 11.27
Introduction
Laravel is a popular PHP web framework that provides a lot of advantages for developers. Some of its main advantages are its dependability, efficiency and a strong developer community. It offers a lot of functionalities like Blade templating, Eloquent ORM, Artisan CLI, authentication, CSRF protection, modular architecture, dependency injection, and a package ecosystem. These functions make Laravel a very well-known and important framework for developing high-quality, resourceful, and safe web applications.
It is important to stay updated and in the know-how about the latest Laravel updates. These upgrades also let us know about the latest features, improvements, bug fixes and security parameters that can improve your development experience. It is vital for the safety and performance of the web applications, also keeping an eye on the best practices in web development. This blog gives you an overview on the latest Laravel 11.26 and 11.27 features.
Evolution of Laravel
According to Wikipedia, the Laravel beta version was released on 9th June’2011. There has been rapid evolution and developments since then for the web framework. Let’s look at some of its history.
-
Gained Popularity: Laravel had a lot of new functionalities like routing, authentication, and views. It had more uses because of its clean syntax.
-
More importance to Developer Experience: It had a lot of new features like Blade Templating, Artisan commands and made development easy with fresh testing capabilities.
-
Transition to Modern Practices: Laravel shifted modern trends like package management with front end frameworks like Vue.js and React.js with Composer.
-
Long Term Support: Laravel introduced LTS versions for stability but with 8.0 all the major updates received support for 2 years.
-
Latest Version: The present stable version of October 2024 will give support until September 2025 for fixing bugs and March 2026 for fixing security.
The following are the most recent Laravel release dates
-
Laravel 10 was released on 14th February’2023.Security updates will be applicable until 4th February’2025, and until 6th August’2024 bug fixes will be applicable.
-
Laravel 11 was released on 12th March’2024.Bug patches for this will be available until 3rd September’2025, and security fixes until 12th March’2026.
Laravel 11.27 Features
Customizable Default Currency in the Number Helper
In Laravel 11.27, a new feature helps developers to set a global default currency for the Number helper. While USD remains the default, this helps you to modify the currency setting without having to set it aside in singular cases.
use Illuminate\Support\Number;
// Globally set the default currency to GBP
Number::useCurrency('GBP');
echo Number::currency(2500);
// Outputs: £2,500.00
// Temporarily switch to another currency (e.g., JPY)
Number::withCurrency('JPY', function () {
echo Number::currency(2500);
// Outputs: ¥2,500
});
// Reverts back to GBP after the temporary switch
echo Number::currency(2500);
// Outputs: £2,500.00
With this functionality, developers can mostly manage currency formatting in their applications.
Introducing the Str::doesntContain() Method
A new `doesntContain()` method has been added to the `Str` helper, making it easy to check if a string does *not* contain certain substring. It’s essentially the inverse of the `contains()` method.
use Illuminate\Support\Str;
$text = 'Laravel is a powerful framework';
// Check if the string doesn't contain specific words
$result1 = Str::doesntContain($text, 'Django'); // true
$result2 = Str::doesntContain($text, 'Laravel'); // false
// Multiple string checks
$result3 = Str::doesntContain($text, ['Rails', 'Symfony']); // true
$result4 = Str::doesntContain($text, ['Rails', 'Laravel']); // false
This method is mostly useful for negating string conditions with greater readability.
Optimized Schema:hasTable() Performance
Performance improvements have been made to the `Schema::hasTable()` method. Previously, this method could generate costly queries. Laravel 11.27 optimizes it by using more efficient database queries, reducing the overall load and making schema checks faster.
use Illuminate\Support\Facades\Schema;
// Check if a table exists with optimized query
if (Schema::hasTable('users')) {
// Perform some action
}
This upgrade improves performance when dealing with large or complex databases.
Str::inlineMarkdown() Extension Support
Laravel 11.27 expands the `Str::inlineMarkdown()` method, allowing you to use markdown extensions. This feature aligns with a previous update (Laravel 11.14) that added extension support to the `markdown()` method.
use Illuminate\Support\Str;
// Parse markdown with extensions
echo Str::inlineMarkdown('This is **bold** text.', [
'extension' => 'my-custom-extension',
]);
This makes it easier to extend and customize the markdown parsing behavior within Laravel applications.
Programmatically Adjust Middleware Priority in HTTP Kernel
Laravel 11.27 offers new methods for adding middleware to the HTTP kernel's priority stack relative to other middleware. This is especially useful for package developers or those managing complex middleware configurations.
Two new methods—`addToMiddlewarePriorityAfter()` and `addToMiddlewarePriorityBefore()`—enable fine-grained control over middleware execution order.
use Illuminate\Foundation\Http\Kernel;
$kernel = app(Kernel::class);
// Add new middleware after a specific one
$kernel->addToMiddlewarePriorityAfter(
\Illuminate\Routing\Middleware\SubstituteBindings::class,
[
\App\Http\Middleware\CustomMiddleware::class,
]
);
// Add new middleware before a specific one
$kernel->addToMiddlewarePriorityBefore(
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
[
\App\Http\Middleware\AnotherCustomMiddleware::class,
]
);
This functionality simplifies the management of middleware priority, offering more control to developers without requiring manual edits from users.
Laravel 11.26 Features
Backed Enum Support for Rate Limiters
Laravel v11.26 introduces the capability to use `BackedEnum` and `UnitEnum` when registering rate limiters. This functionality helps enums to define rate limits in a more expressive and controlled manner.
use Illuminate\Support\Facades\RateLimiter;
use App\Enums\ApiRateLimit;
RateLimiter::for(ApiRateLimit::GOOGLE_API, function () {
return Limit::perMinute(60);
});
RateLimiter::for(ApiRateLimit::MAILCHIMP, function () {
return Limit::perHour(100);
});
You can also apply this feature in job middleware, where rate limits can be defined using enums:
use Illuminate\Queue\Middleware\RateLimited;
use App\Enums\ApiRateLimit;
public function middleware(): array
{
return [
new RateLimited(ApiRateLimit::GOOGLE_API),
];
}
Enums help optimize managing rate limiters and make your code more intuitive and organized.
New Artisan Command to Create Job Middleware
Davey Shafik added a new `make:job-middleware` Artisan command, making it easier to generate job middleware. This command creates the necessary boilerplate for middleware used in Laravel's job system.
```bash
php artisan make:job-middleware ApiRateLimited
```
This will create a job middleware in the `App\Jobs\Middleware` namespace, which you can then personalize according to your requirements.
Efficient Process Stopping with stop() Method
Mathias Hansen contributed the ability to easily stop a running process or a pool of processes using the `stop()` method. This feature helps you to manage processes more smoothly and make certain they exit easily when stopped.
Single Process Example:
use Symfony\Component\Process\Process;
$process = Process::fromShellCommandline('php artisan import:data')->start();
// Other operations...
$process->stop(); // Gracefully stops the process
Process Pool Example:
use Symfony\Component\Process\Pool;
$pool = Process::pool(function (Pool $pool) {
$pool->command('php artisan task:one');
$pool->command('php artisan task:two');
})->start();
// Gracefully stop all processes in the pool
$pool->stop();
// You can also stop with a specific signal
$pool->stop(SIGTERM);
This update is useful for handling long-running processes or pools that need to be terminated in a controlled method.
Improved make: model Command with Factory Annotation
Before Laravel 11.26, model stubs looked like this:
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
use HasFactory;
}
With Laravel 11.26, the generated model now includes a factory type annotation, improving IDE support:
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/** @use HasFactory<\Database\Factories\ProductFactory> */
class Product extends Model
{
use HasFactory;
}
This helps IDEs understand which factory type corresponds to the model, improving the developer experience.
Laravel 11.26 brings important updates and improvements, making your development workflow more efficient and code more organized. These features make managing processes, rate limiting, and generating models with factory annotations much simpler.
When should you Upgrade to 11.27?
Laravel 11.27 offers a variety of improvements that improve applications' performance. Here are some scenarios where updating to Laravel 11.27 would be especially beneficial.
-
Your New Project Is About to Begin: New applications especially benefit from the simplified application structure, which makes it simpler to install and manage.
-
You Depend on Model Casting: The new method-based approach can make your code simpler if your application makes substantial use of model casts.
-
Performance in Testing Is Essential: If you use in-memory databases for extended testing, the performance enhancements can cut down on the amount of time you spend testing.
Laravel 11.27 is a strong choice for developers looking to leverage its streamlined features and performance enhancements, particularly in new projects or those heavily reliant on database interactions.
#shortcode1
When Should You Upgrade to Laravel 11.26 ?
Numerous improvements are included in Laravel 11.26 with the objective of improving performance and productivity. Here are some scenarios where upgrading to Laravel 11.26 would be especially beneficial:
-
Your App Depends on Background Jobs: The new graceful process management can help assure more reliable and seamless functioning if your app relies on background processes.
-
You Use Rate limitation: Using Enums will simplify and organize your code if your project needs rate limitation.
-
You Want a Better Experience as a Developer: An important benefit for time-pressed developers is that the improved Artisan commands and model factory annotations make the development process easier to understand and control.
-
You have PHP 8.2 or higher installed: Before switching, make sure your development environment is up to date because Laravel 11.x requires PHP 8.2.
If you want to improve your apps' performance, reliability, and developer experience, Laravel 11.26 is a good upgrade. It has a ton of features that improve the effectiveness and maintenance of coding, particularly when working with rate limiting or background processes. To fully utilize these new features and expedite your development process, think about upgrading to Laravel 11.26 if your setup meets PHP requirements.
Finally, evaluating your unique requirements and preferences is the best method to determine whether to use Laravel 11.26 or 11.27. Get feedback from other Laravel developers or study the official Laravel documentation if you are unsure which version to use.
Laravel 11.26 and Laravel 11.27 are both outstanding versions of the well-liked PHP framework. if you're searching for a strong yet user-friendly framework for your upcoming project.
Conclusion
With each new version, Laravel keeps improving, and 11.26 and 11.27 offer key upgrades to improve scalability, and increase performance. Both 11.26 and 11.27 provide developers powerful new features, ranging from the ability to use enums with rate limiting, add job middleware more efficiently, and gracefully stop process pools to 11.27's improved string handling, configurable default currency in the Number helper, and middleware priority management.