This week, the Laravel team released v11.12, which includes a multiply collection method, automatically chopping the .php
extension in make
commands, and more.
Chop PHP Extension When Passed to make
Commands (v11.11.1)
Jason McCreary contributed a nice DX feature when passing .php
to make:*
commands for generating files for things like controllers, events, commands, etc. Nothing changes except that Laravel now handles the .php
extension behind the scenes:
php artisan make:controller UserController.php
# Before - app/Http/Controllers/UserController.php.php
# After - app/Http/Controllers/UserController.php
It's painful when you accidentally do this because you have to either move the files or delete them and recreate everything. It's not clear if the command will take care of chopping the extension when typing, so this is a nice touch to some hidden pain—at least for me ;)
Add multiply()
Method to Collections
<iframe width="1185" height="667" src="https://www.youtube.com/embed/AWvXjUnUdw8" title="Laravel collections now include a "multiply" method" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
Patrick O'Meara contributed a multiply()
method to collections, which multiplies the items in the collection. It works by multiplying the existing values on the collection x
number of times:
$c = collect([
['name' => 'User #1', 'email' => 'user1@example.com'],
['name' => 'User #2', 'email' => 'user2@example.com'],
])->multiply(2);
The collection above would look as follows after calling multiply(2)
:
Add Event Discovery Paths to the Event Service Provider
@Jascha contributed a addEventDiscoveryPaths()
method to the event service provider if you need to add additional event discovery paths dynamically. This feature isn't typically needed, but you can do so with:
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] Ensure
schema: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 ingetNameInput
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
andafterMaking
callbacks" by @driesvints in https://github.com/laravel/framework/pull/51858
The post Artisan `make` Commands Automatically Chop `.php` Extension in Laravel 11.12 appeared first on Laravel News.
Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.