When yii2 php namespace introduces third-party non-namespace library files, the error is reported: Class not found solution_PHP tutorial

WBOY
Release: 2016-07-13 09:56:26
Original
1083 people have browsed it

Solution to the error: Class not found when introducing third-party non-namespace library files in yii2 php namespace

A class file is the library method of namespace

Introduce the class in the following way and report an error 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;
    }

}
Copy after login

You need to change $Social_obj= new Social(); to:

$Social_obj= new \Social();
Copy after login

That means adding a backslash, haha, it took me an hour.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/987985.htmlTechArticleyii2 php namespace When introducing a third-party non-namespace library file, an error is reported: Class not found when solving a class file namespace The library method introduces the class in the following way and reports an error Cla...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template