Laravel 11.27 Released
Published on by Paul Redmond
This week, the Laravel team released v11.27, with a configurable default currency in the Number helper, a Str::doesntContain()
method, Schema::hasTable()
performance improvements, and more.
Globally Change the Default Currency of the Number Helper
Ryan Holton contributed a configurable default currency setting for the Number
helper. The USD
currency setting is still the default, but now you can define a different default without using the in
argument to override:
use Illuminate\Support\Number; // Set the default currencyNumber::useCurrency('EUR'); $currency = Number::currency(1000);// €1,000.00 $currency = Number::currency(1000, in: 'USD');// $1,000.00 // Some code that uses USD and defaults back to EUR afterNumber::withCurrency('USD', function () { //});
You can see the example output with this Tinkerwell session:
doesntContain()
method
String Ryan Holton contributed a doesntContain()
method to the Str
helper, which is the inverse of the contains()
method:
use Illuminate\Support\Str; $str = 'My favorite food is Pizza'; Str::doesntContain($str, 'Steak'); // trueStr::doesntContain($str, 'Pizza'); // falseStr::doesntContain($str, ['Steak', 'Spaghetti']); // trueStr::doesntContain($str, ["Steak", "Spaghetti", "Pizza"]); // false
You can see the example output with this Tinkerwell session:
Schema::hasTable()
Performance
Improve Hafez Divandari contributed a performance update to the Schema::hasTable()
method:
The
Schema::hasTable()
method is using theSchema::getTable()
method internally, which could sometimes result in an expensive query. This PR improves the performance ofSchema::hasTable()
by using more lightweight queries.
Str::inlineMarkdown()
Add Extension Support to Ryan Chandler added markdown extension support to the Str::inlineMarkdown()
and str()->inlineMarkdown()
methods, matching the update in Laravel 11.14 to add extension support to the markdown()
method.
HTTP Kernel Methods to Append Middleware Relative to Other Middleware
Ollie Read contributed an update to the HTTP Kernel that allows programmatic insertion of the middleware in relation to existing middleware in the priority stack. Specifically, it introduces two new public methods:
- addToMiddlewarePriorityAfter(): inserts middleware after specified middleware.
- addToMiddlewarePriorityBefore(): inserts middleware before specified middleware.
These changes make it easier for package developers to manage middleware priority without requiring user intervention.
Here are two examples from the pull request description:
$kernel->addToMiddlewarePriorityAfter( \Illuminate\Routing\Middleware\ValidateSignature::class, [ \Illuminate\Cookie\Middleware\EncryptCookies::class, \Illuminate\Contracts\Auth\Middleware\AuthenticatesRequests::class, ],); $kernel->addToMiddlewarePriorityBefore( \Illuminate\Routing\Middleware\ValidateSignature::class, [ \Illuminate\Cookie\Middleware\EncryptCookies::class, \Illuminate\Contracts\Auth\Middleware\AuthenticatesRequests::class, ],);
Release notes
You can see the complete list of new features and updates below and the diff between 11.26.0 and 11.27.1 on GitHub. The following release notes are directly from the changelog:
v11.27.1
- [11.x] Fix border overflow on theme switcher when hovering by @mezotv in https://github.com/laravel/framework/pull/53064
- [11.x] Optimize commands registry by @erikgaal in https://github.com/laravel/framework/pull/52928
- [11.x] Fix laravel/framework#53071 by @it-can in https://github.com/laravel/framework/pull/53072
v11.27.0
- [11.x] feat: narrow types for throw_if and throw_unless by @calebdw in https://github.com/laravel/framework/pull/53005
- [11.x] Prevent calling tries() twice by @themsaid in https://github.com/laravel/framework/pull/53010
- [11.x] Improve PHPDoc by @schulerj89 in https://github.com/laravel/framework/pull/53009
- [11.x] Utilise
Illuminate\Support\php_binary()
by @crynobone in https://github.com/laravel/framework/pull/53008 - [11.x] Set HasAttributes@casts() array generics by @cosmastech in https://github.com/laravel/framework/pull/53024
- [11.x] Improve
Schema::hasTable()
performance by @hafezdivandari in https://github.com/laravel/framework/pull/53006 - [11.x] Always inherit parent attributes by @royduin in https://github.com/laravel/framework/pull/53011
- [11.x] feat: introduce option to change default Number currency by @sts-ryan-holton in https://github.com/laravel/framework/pull/53022
- [11.x] feat: add Str::doesntContain() method and supporting tests by @sts-ryan-holton in https://github.com/laravel/framework/pull/53035
- [11.x] Str: Add extension support for
Str::inlineMarkdown()
by @ryangjchandler in https://github.com/laravel/framework/pull/53033 - Fix: Correct typehint on repository retrieval methods by @liamduckett in https://github.com/laravel/framework/pull/53025
- [11.x] Test for forgetting non-flexible keys for file driver by @timacdonald in https://github.com/laravel/framework/pull/53018
- Add metadata to mailable view data by @TobMoeller in https://github.com/laravel/framework/pull/53042
- [11.x] PHPDoc Improvements by @schulerj89 in https://github.com/laravel/framework/pull/53054
- [11.x] Test Improvements by @toarupg0318 in https://github.com/laravel/framework/pull/53057
- [11.x] PHPDoc Improvements by @seriquynh in https://github.com/laravel/framework/pull/53053
- Add Exception Handling for jsonOptions() Method by @shamimulalam in https://github.com/laravel/framework/pull/53056
- [11.x] Fixes
make:model
for Form Requests by @joshmanders in https://github.com/laravel/framework/pull/53052 - [11.x] Fixes validation using
shouldConvertToBoolean
when parameter uses dot notation by @bytestream in https://github.com/laravel/framework/pull/53048 - [11.x] Add methods to the HTTP kernel to append middleware relative to other middleware by @ollieread in https://github.com/laravel/framework/pull/52897
- [11.x] Add
--json
flag toqueue:work
command for structured logging by @josecl in https://github.com/laravel/framework/pull/52887 - [11.x] Improve performance of Redis queue block_for when a worker has multiple queues to service by @michael-scinocca in https://github.com/laravel/framework/pull/52826