Laravel 11.24 发布
Laravel 发布了 v11.24,新版本包括进程 Fake 的新便捷方式,外键定义的 nullOnUpdate()
方法,任务重试时支持重试多个批处理 ID 等。
app/Console/commands
路径中控制台命令的自动发现在 v11.24.0 中已被破坏。这个问题在 v11.24.1 中很快得到了修补。
建议等待补丁更新,如果你的更新和应用控制台命令丢失,这可能会让你感到困惑。
添加 prependLocation()
到 View 工厂
Noboru Shiroiwa 添加了 prependLocation()
方法到 View 工厂,你可用在 View
Facade 中使用该方法:
// 之前
View::getFinder()->addLocation($path); // ✅
View::getFinder()->prependLocation($path); // ✅
View::addLocation($path); // ✅
View::prependLocation($path); // ❌
// 之后
View::prependLocation($path); // ✅
添加 nullOnUpdate()
方法到外键定义(ForeignKeyDefinition)
Gisu Nasrollahi 贡献了 nullOnUpdate()
方法到 ForeignKeyDefinition
schema 类,这表示对引用模型的更新应将外键值设置为 null
。
$table->foreign('user_id')
->references('id')
->on('users')
->nullOnUpdate();
允许 Route::can()
中使用回退枚举(BackedEnum)
@Omegadela 在 Route::can()
方法中贡献了回退枚举的支持:
// 之前
Route::post('/request', function () {...})->can(Permissions::CAN_REQUEST->value);
// 之后
Route::post('/request', function () {...})->can(Permissions::CAN_REQUEST);
Process Fake 结果快捷方式
Jason McCreary 为进程(Process) Fake 结果添加了两个结果快捷方式。下面第一个例子是设置退出码的便捷方式。第二个例子为抛出异常的便捷方式。
Process::fake([
'php -l script.php' => 255,
'cat README.txt' => new \RuntimeException('fake exception message'),
]);
以下是来自相关 PR 测试中的 Fake 操作:
// 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');
重试识别任务时支持重试多个批处理 ID
Sean Kegel 更新了 queue:retry-batch
命令以接受多个 ID,这样多个任务可以一次性重试:
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 to Route::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)() to ProcessDriver[@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 for Cache::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