Laravel 11.12:Artisan make 命令自动剪切 .php 后缀
Laravel 团队发布了 v11.12,其中包括 multiply 集合方法,在 make
命令中自动剪切 .php
扩展名等。
当传入 make 命令时剪切 PHP 后缀名 (v11.11.1)
Jason McCreary在传递 .php
到 make:*
命令时提供了一个很好的开发者体验特性,用于为控制器、事件、命令等生成文件。除了现在在幕后处理 .php
后缀之外,没有任何变化:
php artisan make:controller UserController.php
# Before - app/Http/Controllers/UserController.php.php
# After - app/Http/Controllers/UserController.php
当你不小心这样做时,会很痛苦,因为你必须移动文件或删除它们并重新创建所有内容。目前尚不清楚该命令是否会在键入时处理扩展插件的问题,所以这对一些隐藏的痛苦来说是一个很好的触动——至少对我来说是这样;)
将 multiply() 方法添加到集合
Patrick O'Meara 为集合提供了一个 multiply()
方法,该方法将集合中的项倍增。它的工作原理是将集合上的现有值乘以 x 次:
$c = collect([
['name' => 'User #1', 'email' => 'user1@example.com'],
['name' => 'User #2', 'email' => 'user2@example.com'],
])->multiply(2);
上例中的集合在调用 multiply(2)
后如下图所示:
![](https://picperf.io/https://laravelnews.s3.amazonaws.com/images/V7Qr1VNk21pgqV8hwEEmAJjejypIwcYiyyR3kSFT.png)
将事件发现路径添加到事件服务提供者
如果你需要动态添加事件发现路径,@Jascha 提供了一个 addEventDiscoveryPaths()
方法到事件服务提供者。该特性不是常规情况下必须的,不过你可以如下这样使用:
use Illuminate\Foundation\Support\Providers\EventServiceProvider;
EventServiceProvider::addEventDiscoveryPaths('/some/path/to/events');
EventServiceProvider::addEventDiscoveryPaths([
'/some/path',
'/another/path'
]);
Release notes
You can see the complete list of new features and updates below and the diff between 11.11.0 and 11.12.0 on GitHub. The following release notes are directly from the changelog:
v11.12.0
- [10.x] Fix typo in return comment of createSesTransport method by @zds-s in https://github.com/laravel/framework/pull/51688
- [10.x] Fix collection shift less than one item by @faissaloux in https://github.com/laravel/framework/pull/51686
- [10.x] Turn Enumerable unless() $callback parameter optional by @faissaloux in https://github.com/laravel/framework/pull/51701
- Revert "[10.x] Turn Enumerable unless() $callback parameter optional" by @taylorotwell in https://github.com/laravel/framework/pull/51707
- [10.x] Fixes unable to call another command as a initialized instance of Command class by @crynobone in https://github.com/laravel/framework/pull/51824
- [10.x] fix handle shift() on an empty collection by @Treggats in https://github.com/laravel/framework/pull/51841
- [10.x] Ensureschema:dump will dump the migrations table only if it exists by @NickSdot in https://github.com/laravel/framework/pull/51827
- [11.x] Test Improvements by @crynobone in https://github.com/laravel/framework/pull/51847
- [11.x] Test application storage path by @seriquynh in https://github.com/laravel/framework/pull/51848
- [11.x] Fix PHP_MAXPATHLEN check for strings slightly smaller then PHP_MAXPATHLEN by @joshuaruesweg in https://github.com/laravel/framework/pull/51850
- [11.x] Improve Bus::assertNothingDispatched(), Event::assertNothingDispatched(), Mail::assertNothingSent(), Notification::assertNothingSent() error messages by @macbookandrew in https://github.com/laravel/framework/pull/51846
- [11.x] Update error page to show GET by @chu121su12 in https://github.com/laravel/framework/pull/51837
- [11.x] Remove deprecated type attributes in the exception renderer by @osbre in https://github.com/laravel/framework/pull/51866
- [11.x] Import classes in the exception templates by @osbre in https://github.com/laravel/framework/pull/51863
- [11.x] Collection before/after optimization by @bert-w in https://github.com/laravel/framework/pull/51876
- [11.x] Add multiply to collection by @patrickomeara in https://github.com/laravel/framework/pull/51870
- [11.x] Add addEventDiscoveryPaths to EventServiceProvider by @ya-cha in https://github.com/laravel/framework/pull/51896
- [11.x] Fix validation attributes when translations are empty or missing by @owenandrews in https://github.com/laravel/framework/pull/51890
- [11.x] feat: add generics to tap() helper by @calebdw in https://github.com/laravel/framework/pull/51881
v11.11.1
- [11.x] Remove useless variable assignment by @seriquynh in https://github.com/laravel/framework/pull/51838
- [11.x] Fix event dispatcher typing in cache repository by @axlon in https://github.com/laravel/framework/pull/51835
- Chop PHP extension when passed to make commands by @jasonmccreary in https://github.com/laravel/framework/pull/51842
- [11.x] Simplify .php extension chopping in getNameInput by @osbre in https://github.com/laravel/framework/pull/51843
- [11.x] fix: improve performance and robustness of Relation::getMorphAlias() by @calebdw in https://github.com/laravel/framework/pull/51845
- Revert "[11.x] Change scope for afterCreating and afterMaking callbacks" by @driesvints in https://github.com/laravel/framework/pull/51858