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”。 –