The Laravel team released v11.24 this week, with new shorthands
for Process fakes, a nullOnUpdate()
method for foreign
key definitions, support for retrying multiple batch IDs when
retrying jobs, and more.
A quick note that as of the time of writing, auto-discovery of
console commands in the app/Console/Commands
path.
This issue likely gets patched quickly, but if you want to update
to 11.24.0, you can add the following to
bootstrap/app.php
:
Application::configure(basePath: dirname(__DIR__))
// ...
->withCommands([
__DIR__.'/../app/Console/Commands'
]);
I'd recommend waiting for a patch update, but this could confuse you if you update and application console commands are missing.
Add prependLocation()
to View Factory
Noboru Shiroiwa added the
prependLocation()
method to the View factory, which
enables you to use the method with the View
facade:
// Before
View::getFinder()->addLocation($path); // ✅
View::getFinder()->prependLocation($path); // ✅
View::addLocation($path); // ✅
View::prependLocation($path); // ❌
// After
View::prependLocation($path); // ✅
Add nullOnUpdate()
Method to
ForeignKeyDefinition
Gisu Nasrollahi contributed a
nullOnUpdate()
method to the
ForeignKeyDefinition
schema class, which indicates
that updates on the referenced model should set the foreign key
value to null.
$table->foreign('user_id')
->references('id')
->on('users')
->nullOnUpdate();
Allow BackedEnum
to be Used With
Route::can()
@Omegadela contributed support for backed enums in the
Route::can()
method:
// Before
Route::post('/request', function () {...})->can(Permissions::CAN_REQUEST->value);
// After
Route::post('/request', function () {...})->can(Permissions::CAN_REQUEST);
Add Result Shorthands for Process
Fakes
Jason McCreary contributed two new result
shorthands for Process
fake results in tests. The
first example is a shorthand to set the exit code. The second
example is a shorthand for throwing an exception.
Process::fake([
'php -l script.php' => 255,
'cat README.txt' => new \RuntimeException('fake exception message'),
]);
Here's an example of the fake in action from the Pull Request's tests:
// Exit code example
$factory = new Factory;
$factory->fake(['ls -la' => 1]);
$result = $factory->run('ls -la');
$this->assertSame(1, $result->exitCode());
$this->assertFalse($result->successful());
// Exception example
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('fake exception message');
$factory = new Factory;
$factory->fake(['cat me' => new \RuntimeException('fake exception message')]);
$factory->run('cat me');
Support Multiple Batch IDs When Retrying Failed Batch Jobs
Sean Kegel updated the queue:retry-batch
command to accept multiple IDs so that multiple jobs can be retried
at once:
php artisan queue:retry-batch \
'9d0ed667-8c3a-4385-8a07-aff118a21e5c' \
'9d0ed6f1-b8dd-486b-8761-f89de0fb68e3'
Release notes
You can see the complete list of new features and updates below and the diff between 11.23.0 and 11.24.0 on GitHub. The following release notes are directly from the changelog:
v11.24.0
- [11.x] Fix issue where
$name
variable in non base config file becomes it's key by @rojtjo in https://github.com/laravel/framework/pull/52738 - [11.x] PHPDoc Improvements by @amitmerchant1990 in https://github.com/laravel/framework/pull/52797
- [11.x] Remove a unused import and fix docblock for DeferredCallbackCollection by @seriquynh in https://github.com/laravel/framework/pull/52808
- [11.x] Handle SQLSTATE[HY000] [2002] Operation now in progress in DetectsLostConnection trait #52759 by @webartisan10 in https://github.com/laravel/framework/pull/52805
- [11.x] Add prependLocation method to View Factory by @nshiro in https://github.com/laravel/framework/pull/52806
- [11.x] add nullOnUpdate() method to ForeignKeyDefinition by @gisuNasr in https://github.com/laravel/framework/pull/52798
- [11.x] Allow
BackedEnum
to be passed toRoute::can()
by @Omegadela in https://github.com/laravel/framework/pull/52792 - [11.x] Ensure headers are only attached to illuminate responses by @timacdonald in https://github.com/laravel/framework/pull/52789
- [11.x] feat: improve Collection groupBy, keyBy generics by @calebdw in https://github.com/laravel/framework/pull/52787
- [11.x] Using Correct
Concurrency
Configuration Index Name by @devajmeireles in https://github.com/laravel/framework/pull/52788 - [11.x] Ensure
withoutPretending
method properly resets state after callback execution by @xurshudyan in https://github.com/laravel/framework/pull/52794 - [11.x] delegate
ProcessDriver[@defer](https://github.com/defer)()
toProcessDriver[@run](https://github.com/run)()
method by @rodrigopedra in https://github.com/laravel/framework/pull/52807 - [11.x] Use command string instead of array on
Concurrency\ProcessDriver
by @rodrigopedra in https://github.com/laravel/framework/pull/52813 - [11.x] Allows Laravel Framework to correctly resolve PHP binary when running via Laravel Herd by @crynobone in https://github.com/laravel/framework/pull/52791
- [11.x] Move Defer classes to Support component and add
Illuminate\Support\defer
function by @crynobone in https://github.com/laravel/framework/pull/52801 - [11.x] Suggest
laravel/serializable-closure
on Database component by @crynobone in https://github.com/laravel/framework/pull/52835 - Bump vite from 5.2.10 to 5.2.14 in /src/Illuminate/Foundation/resources/exceptions/renderer by @dependabot in https://github.com/laravel/framework/pull/52834
- [11.x] Update Concurrency component's composer dependencies by @rodrigopedra in https://github.com/laravel/framework/pull/52836
- Add result shorthands for
Process
fakes by @jasonmccreary in https://github.com/laravel/framework/pull/52840 - Update SerializesCastableAttributes to include array generics by @cosmastech in https://github.com/laravel/framework/pull/52841
- [11.x] CI Improvements by @crynobone in https://github.com/laravel/framework/pull/52850
- [11.x] Supports
laravel/prompts
v0.2 by @crynobone in https://github.com/laravel/framework/pull/52849 - [11.x] Handle allows null parameter instead of requiring default value by @crynobone in https://github.com/laravel/framework/pull/52866
- [11.x] Adds
[@throws](https://github.com/throws)
section to Concurrency manager doc block by @rnambaale in https://github.com/laravel/framework/pull/52856 - Update stub to remove unused trait imports by @lombervid in https://github.com/laravel/framework/pull/52877
- [11.x] Fix validation rule type hints by @axlon in https://github.com/laravel/framework/pull/52870
- [11.x] Support multiple batch IDs when retrying failed batch jobs by @skegel13 in https://github.com/laravel/framework/pull/52873
- [11.x] Remove unused namespaces from DatabaseInspectionCommand and LocalFileSystemAdapter by @saMahmoudzadeh in https://github.com/laravel/framework/pull/52868
- [11.x] Auto-register commands in
routes/console.php
by @SamuelNitsche in https://github.com/laravel/framework/pull/52867 - [11.x] Prevent infinite recursion on
touchesParents()
for chaperoned models by @samlev in https://github.com/laravel/framework/pull/52883 - Bump rollup from 4.17.1 to 4.22.4 in /src/Illuminate/Foundation/resources/exceptions/renderer by @dependabot in https://github.com/laravel/framework/pull/52892
- [11.x]
Cache::flexible
improvements by @timacdonald in https://github.com/laravel/framework/pull/52891 - [11.x] Add
\DateTimeInterface
and\DateInterval
to type forCache::flexible()
by @bram-pkg in https://github.com/laravel/framework/pull/52888 - [11.x] CI Improvements by @crynobone in https://github.com/laravel/framework/pull/52851
- [11.x] Do not trigger missing translation key handling when checking existence of translation key by @gdebrauwer in https://github.com/laravel/framework/pull/52895
The post Laravel 11.24 Released appeared first on Laravel News.
Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.
Read more https://laravel-news.com/laravel-11-24-0