I'm using the Google PHP Library that I've installed via Composer.
"google/apiclient": "*"
I can run the test code in the view but when I try to run it in the Controller I get an error.
Class 'backend\controllers\Google_Client' not found
Here is the Test code
$client = new Google_Client();
$client->setApplicationName("Client_Library_Examples");
$client->setDeveloperKey("***********************");
$service = new Google_Service_Books($client);
$optParams = array('filter' => 'free-ebooks');
$results = $service->volumes->listVolumes('Henry David Thoreau', $optParams);
Class 'backend\controllers\Google_Client' not found
It seems like you didn't define namespace using.
use Google\Google_Client; //or somethong like this
If Google_Client hasn't namespace use require
to import class from file
require \Yii::getAlias('common/components/simple_html_dom') . '.php';
I think Google_Client don't use namespaces. So use "\".
$client = new \Google_Client();