Mr Rost Mr Rost - 1 month ago 27
PHP Question

Unknown component ID: authClientCollection

Im doing my site like this tutorial, https://www.mushtaqtahir.com/blog/2/facebook-authentication-using-yii2-authclient
but when I'm trying to going to my localhost/basic/web/index.php I have that error:

Invalid Configuration – yii\base\InvalidConfigException

Unknown component ID: authClientCollection


in basic\vendor\yiisoft\yii2\di\ServiceLocator.php

maybe its problem in my config. I haven't in my config folder main.php file and I creating it and add data like in tutorial.

Answer

Check in you basic/config/web.php and add in component section the requiredc params

'components' => [
    'authClientCollection' => [
      'class' => 'yii\authclient\Collection',
      'clients' => [
        'facebook' => [
          'class' => 'yii\authclient\clients\Facebook',
          'authUrl' => 'https://www.facebook.com/dialog/oauth?display=popup',
          'clientId' => 'YOUR APP CLIENT ID',
          'clientSecret' => 'YOUR APP CLIENT SECRET',
          'attributeNames' => ['name', 'email', 'first_name', 'last_name'],
        ],
      ],
    ],
.....
],