-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.4] Bind no longer accepts an array containing aliases. #17793
Comments
check your syntax and please share the error you receive. |
Sorry, I've updated the code to include the missing bracket. I'll get an exact error message for you shortly. |
Ok, on a blank L5.4 install using this in the app service provider. <?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->app->bind(['some.alias' => \Illuminate\Support\Str::class], function () {
return new \Illuminate\Support\Str();
});
}
} I get the following error:
|
The commit that removed the functionality: 1a1969b
|
$this->app->alias(\Illuminate\Support\Str::class, 'some.alias'); You just have to refactor it... |
@fernandobandeira Thanks, thats what I've done. It's not great when a feature that can break quite a lot and throws an error message that doesn't really help out is just randomly removed. This really should be something documented in the migration docs from 5.3 to 5.4. The comment in the commit also mentions that it was not documented, there was a comment that explained the functionality so it was. |
Removing some old methods such as share() in favor of the more common and documented singleton().
@jralph sorry about that, it should have been documented. Will make sure to include that in the upgrade guide. |
Docs updated, thanks :) |
This is crazy. What is the reason for removing this? Surely it can stay, as obviously people are using it. |
I agree. Removing code because "I've also never seen anyone use that..." is how you break things. Sort of like a car engineer say "I've never seen people use brakes, so I'm removing them." without any warning or telling the new car users that the brakes are missing. |
@jralph Unfortunately Laravel does have history with that mantra. |
Description:
In 5.4 it is no longer possible to use bind by passing in an array with an alias. This change doesn't appear to be documented anywhere, and the given error message when this fails doesn't help identify the problem that easily.
Steps To Reproduce:
Put this code in a service provider.
The text was updated successfully, but these errors were encountered: