我是yii2框架的php web开发的新手。我正在开发一个Web应用程序,我在main.php文件(config文件夹)的返回中几乎没有变量。
return [
'components' => [
'authClientCollection' => [
'class' => 'yii\authclient\Collection',
'clients' => [
'facebook' => [
//some fields
],
'google' => [
'class' => 'yii\authclient\clients\GoogleOAuth',
'clientId' => 'somerandomnumber.apps.googleusercontent.com',
'clientSecret' => '6f7g8h9i10j',
],
],
],
]
我必须在Model文件夹的php文件中使用google's clientId
。
<a href="https://accounts.google.com/o/oauth2/auth?redirect_uri=http%3A%2F%2FCURRENT-DOMAIN%2Fgoogle%2Dlogin&response_type=permission&scope=email+profile+openid&client_id=GET THE CLIENT ID HERE">
<div class="gplus_seperator">
<div class="social_logo">
<span class="icon-font">p</span>
</div>
<div class="social_text">Sign in with Google+</div>
</div>
</a>
有人可以帮助我。 TIA
答案 0 :(得分:2)
您可以使用以下方式访问组件:
Yii::$app->components['authClientCollection']['clients']['google']['clientId'];