Laravel服务提供商“Unresolvable dependency”

时间:2017-09-22 20:49:27

标签: php laravel-5 laravel-socialite

我有一个在互联网上似乎相当普遍的问题,但我担心我无法确定解决方案。

错误

BindingResolutionException in Container.php line 888:
Unresolvable dependency resolving [Parameter #0 [ <required> $app ]] in class Illuminate\Support\ServiceProvider

服务提供商(Providers / SocialAccountServiceProvider.php)

这是我相对简单的服务提供商。

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;
    }
}

注册(config / app.php)

我已经在应用程序中注册了服务提供商。

App\Providers\SocialAccountServiceProvider::class,

Controller(Controllers / TwitterAuthController.php)

我的控制器也非常简单。

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

0 个答案:

没有答案