invisnik / laravel-steam-auth

Laravel Steam Auth
MIT License
172 stars 67 forks source link

[5.4] Share method removed #43

Closed RonMelkhior closed 7 years ago

RonMelkhior commented 7 years ago

In Laravel 5.4, the share method was deleted and it is mentioned libraries should use singeleton.

Code in question

Docs:

https://laravel.com/docs/5.4/upgrade#upgrade-5.4.0

The share method has been removed from the container. This was a legacy method that has not been documented in several years. If you are using this method, you should begin using the singleton method instead:

$container->singleton('foo', function () {
    return 'foo';
});

EDIT: I have submitted a PR (#44) to fix this.

bensherred commented 7 years ago

I have also encountered this issue tonight.

After reading the documentation and testing you can fix this by doing the following:

1. Open up \vendor\invisnik\laravel-steam-auth\src\SteamServiceProvider,php

2. Change the following in the register() function

$this->app['steamauth'] = $this->app->share( function () { return new SteamAuth(); } );

to

$this->app->singleton('SteamAuth', function($app) { return new SteamAuth($app['SteamAuth']); });

RonMelkhior commented 7 years ago

directly modifying vendor packages is a bad habit. seeing as you should not upload the vendor directory to your VCS repo.

Also no need for the constructor argument in your code. See my PR for a good example.

On Jan 25, 2017 12:18 AM, "Ben" notifications@github.com wrote:

I have also encountered this issue tonight.

After reading the documentation and testing you can fix this by doing the following:

1. Open up \vendor\invisnik\laravel-steam-auth\src\SteamServiceProvider,php

2. Change the following in the register() function

$this->app['steamauth'] = $this->app->share( function () { return new SteamAuth(); } );

to

$this->app->singleton('SteamAuth', function($app) { return new SteamAuth($app['SteamAuth']); });

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/invisnik/laravel-steam-auth/issues/43#issuecomment-274957539, or mute the thread https://github.com/notifications/unsubscribe-auth/AA-HeZ6LbNB23nNiyBL71LP6yQoumBOeks5rVni4gaJpZM4LsxNk .

bensherred commented 7 years ago

I am suggesting this is what needs to be changed in the package, of course editing the vendor is not suggested but until the package is updated this is a way of fixing it.

And yes I forgot to remove that due to using an example from the Laravel Docs.

RonMelkhior commented 7 years ago

The PR was merged and a new release is out (v2.3.2).