laravel 5.3でGoogleログインを実装しようとしています。最初、私はエラーを得た、しかしcomposer require hybridauth/hybridauth
Laravel 5でHybridAuthを使用するエラーHybrid_Authクラスを宣言できません
::私は作曲を使用してhybridauthインストールだから私はHybridauth(プロジェクト内のパス内の各クラスに名前空間namespace Hybridauth;
を追加
:ベンダー/ hybridauth/hybridauth/hybridauth /ハイブリッド)を使用して私のコントローラーにそれを組み込んだ、Hybridauth \ Hybrid_Auth;私はプロジェクト全体と"Class Hybrid_Auth not found"
Hybrid_Auth
は一度だけ宣言されたクラスを検索したにもかかわらず
FatalErrorException in Auth.php line 16: "Cannot declare class Hybridauth\Hybrid_Auth, because the name is already in use"
:しかし、今、私はエラーを取得します。
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Hybridauth\Hybrid_Auth;
class AuthController extends Controller
{
public function googleLogin($auth=null)
{
if($auth == 'auth')
{
try
{
Hybrid_Endpoint::process();
}
catch(Exception $e)
{
return Redirect::to('googleAuth');
}
return;
}
$config = array(
"base_url" => "localhost:8000/gauth",
"providers" => array (
"Google" => array (
"enabled" => true,
"keys" => array ("id" => "googleIdGoeshEre", "secret" => "googleSecretKeyGoeshEre"),
"scope" => "https://www.googleapis.com/auth/userinfo.profile ". // optional
"https://www.googleapis.com/auth/userinfo.email" , // optional
"access_type" => "offline", // optional
"approval_prompt" => "force", // optional
"hd" => "domain.com" // optional
)));
$oauth = new Hybrid_Auth($config);
$provider = $oauth->authenticate("Google");
$profile = $provider->getUserProfile();
return var_dump($profile).'<br><a href="logout">Logout</a>';
}
}
?>