0
我正在服務提供者中註冊我的社交認證服務,我的接口的實現需要參數在其構造函數中。如何在Laravel服務提供者中傳遞構造函數依賴關係
如何通過服務提供者傳遞它?這是我的代碼,但它在語法上不正確。
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App;
use App\User;
use Illuminate\Contracts\Auth\Guard;
use Laravel\Socialite\Contracts\Factory as Socialite;
class SocialAuthenticationServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
App::bind('App\Repositories\SocialAuthenticationInterface', function() {
return new App\Repositories\SocialAuthentication(Socialite $socialite, Guard $auth, User $user);
});
}
}
它返回一個致命錯誤,「無法實例化界面Laravel \ Socialite \ Contracts \ Factory」。 –