码迷,mamicode.com
首页 > Web开发 > 详细

yii2 php namespace 引入第三方非namespace库文件时候,报错:Class not found 的解决

时间:2015-04-20 21:00:09      阅读:335      评论:0      收藏:0      [点我收藏+]

标签:

一个类文件时namespace的库方式

通过下面的方式引入类,报错  Class Not Found:

namespace frontend\block\customer\account;
use Yii;
use frontend\block\Blockbase;
//use yii\base\Model;
//use backend\models\helper\Base.php
use frontend\models\core\Request;
use frontend\models\core\Customer;
use frontend\models\core\User;
use frontend\models\core\Url;
use frontend\models\core\Func;
use frontend\models\core\Email;
use frontend\models\core\Help;
use frontend\models\core\Session;
use frontend\models\core\Config;
use frontend\models\core\Store;
use frontend\models\core\Message;
use frontend\models\core\Date;
use frontend\models\core\Mongodb;

use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\Entities\AccessToken;
use Facebook\HttpClients\FacebookCurlHttpClient;
use Facebook\HttpClients\FacebookHttpable;



class Login extends Blockbase
{
   

public function getGoogleLoginUrl(){
        $lib_google_base = Yii::getAlias("@common/lib/google");
        //echo $lib_google_base.'/Social.php';exit;
        $lib_google_base = Yii::getAlias("@common/lib/google");
        include $lib_google_base.'/Social.php';
        $Social_obj= new Social();

        $url = $Social_obj->google();
        return $url;
    }

}

需要把$Social_obj= new Social(); 改成:

$Social_obj= new \Social();

也就是加入一个反斜杠,哈哈,折腾了我1个小时。


yii2 php namespace 引入第三方非namespace库文件时候,报错:Class not found 的解决

标签:

原文地址:http://blog.csdn.net/terry_water/article/details/45154011

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!