2013-12-18 4 views
0

Я пытаюсь использовать hybridauth version 2.1.2 и используя this tutorial to install it., к сожалению, я получаю эту ошибку.не удалось открыть поток: нет такого файла или каталога

include(/Applications/XAMPP/xamppfiles/htdocs/dev/protected/extensions/components/HybridAuthIdentity.php): failed to open stream: No such file or directory 

моя структура каталогов как таковой

/*numbers indicate the folder or file depth*/ 
1 components 
    2 HybridAuthIdentity.php 

1 controllers 
    2 SiteController.php 

1 extensions 
    2 HybridAuth 
    3 hybridauth-2.1.2 
     4 hybridauth 
     5 index.php 
     5 Hybrid 
      6 Auth.php 

почему он ищет файл в этом каталоге protected/extensions/components вместо просто protected/components? я отредактировал мой actionLogin() (ниже) я думаю, что ошибка в этой строке Yii::import('ext.components.HybridAuthIdentity');

ошибка появляется, когда я нажимаю на это на моей странице входа (моя страница Войти в http://mysite/login)

<a href="http://mysite/login?provider=facebook" ><img src="images/buttons/facebook.png" /></a> 

Может кто-нибудь мне помочь? заранее спасибо.

/** 
    * Displays the login page 
    */ 
    public function actionLogin() { 
     //action only for the login from third-party authentication providers, such as Google, Facebook etc. Not for direct login using username/password 
     if (!isset($_GET['provider'])) 
     { 
      if(app()->user->isGuest()){ 
       $model = new LoginForm; 

       // if it is ajax validation request 
       if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') { 
        echo CActiveForm::validate($model); 
        app()->end(); 
       } 

       // collect user input data 
       if (isset($_POST['LoginForm'])) { 
        $model->attributes = $_POST['LoginForm']; 
        // validate user input and redirect to the previous page if valid 
        if ($model->validate() && $model->login()) { 
         $user = app()->user->getUser(); 
         User::model()->updateByPk($user->id, array('last_login' => new CDbExpression('NOW()'))); 
         if (isset($_POST['ajax'])) { 
          echo app()->user->getHomeUrl(); 
          app()->end(); 
         } else { 
          $this->redirect(app()->user->returnUrl); 
         } 
        } else { 
         if (isset($_POST['ajax'])) { 
          echo "bad"; 
          app()->end(); 
         } else { 
          app()->user->setFlash('error', 'Login failed. Please try again.'); 
         } 
        } 
       } 
       // display the login form 
       $this->render('login', array('model' => $model)); 
      } else { 
       $this->redirect(array('/user/update', 'id' => app()->user->id)); 
      } 
     } 
     else { 
      try 
      { 
       Yii::import('ext.components.HybridAuthIdentity'); 
       $haComp = new HybridAuthIdentity(); 
       if (!$haComp->validateProviderName($_GET['provider'])) 
        throw new CHttpException ('500', 'Invalid Action. Please try again.'); 

       $haComp->adapter = $haComp->hybridAuth->authenticate($_GET['provider']); 
       $haComp->userProfile = $haComp->adapter->getUserProfile(); 

       $haComp->login(); 
       $this->redirect(''); //redirect to the user logged in section.. 

       $haComp->processLogin(); //further action based on successful login or re-direct user to the required url 
      } 
      catch (Exception $e) 
      { 
       //process error message as required or as mentioned in the HybridAuth 'Simple Sign-in script' documentation 
       $this->redirect('/site/index'); 
       return; 
      } 
     } 
    } 

ответ

1

Вы правы. Эта строка должна читать Yii::import('app.components.HybridAuthIdentity'). Однако, поскольку классы в папке components автоматически загружаются, эта строка даже не должна быть там.

+0

'папка компонентов автоматически загружается по умолчанию' узнала что-то новое сегодня :) спасибо – user2636556

Смежные вопросы