我有一个在互联网上似乎相当普遍的问题,但我担心我无法确定解决方案。
BindingResolutionException in Container.php line 888:
Unresolvable dependency resolving [Parameter #0 [ <required> $app ]] in class Illuminate\Support\ServiceProvider
这是我相对简单的服务提供商。
namespace App\Providers;
use App\User;
use Socialite;
use App\SocialAccount;
use Illuminate\Support\ServiceProvider;
class SocialAccountServiceProvider extends ServiceProvider
{
protected $socialNetwork = '';
public function boot()
{
//
}
public function register()
{
//
}
public function resolveTwitterUser()
{
$this->socialNetwork = 'twitter';
return $this->resolveUser();
}
public function resolveFacebookUser()
{
$this->socialNetwork = 'facebook';
return $this->resolveUser();
}
public function resolveUser()
{
return $resolvedUser;
}
}
我已经在应用程序中注册了服务提供商。
App\Providers\SocialAccountServiceProvider::class,
我的控制器也非常简单。
use App\User;
use Socialite;
use App\SocialAccount;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Providers\SocialAccountServiceProvider;
class TwitterAuthController extends Controller
{
public function redirect()
{
return Socialite::driver('twitter')->redirect();
}
public function callback(SocialAccountServiceProvider $account)
{
$user = $account->resolveTwitterUser();
if (Auth::loginUsingId($user->id, true))
return redirect()->to('/');
else
return redirect()->to('/login');
}
}
任何善良的灵魂都愿意帮忙吗?
DEETS:
- Laravel: 5.4
- Socialite: 3.0