I am importing Guzzle library in a Yii project and getting error.

Way of importing

    Yii::import('application.vendor.Guzzle'); 
    require_once(Yii::getPathOfAlias('application.vendor.Guzzle.Http').'/Client.php');      
    $response = Guzzle::get('http://guzzlephp.org'); 

Error

    Fatal error: Class 'Guzzle\Common\AbstractHasDispatcher' not found in C:\wamp\www\yiiproject\protected\vendor\Guzzle\Http\Client.php
有帮助吗?

解决方案

Try with

Yii::import('application.vendor.Guzzle.*');

Right now you are only importing 1 class. You are also including another but the rest of the classes are no where to be found because Yii does not know where to find them.

Better yet, use composer to get guzzle. Composer will create an autoload file that you can easily import with Yii and will in turn load everything else.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top