you don’t need to manually add the vendor/autoload.php. This already happens in your webroot/index.php .
Make sure to either use a FQCN like $client = new \Google\Client(); or add a use statement at the top of your class like
<?php
declare(strict_types=1);
namespace App\Controller;
use Cake\Controller\Controller;
use Google\Client;
class MyController extends Controller
{
public function myGoogleAction()
{
$client = new Client();
}
}
Same problem. If you don’t start a class name with \ then its relative to your current namespace - therefore it tries to load the class App\Controller\Google_Service_Sheets.
This is all very standard PHP namespace stuff, nothing whatsoever to do with CakePHP, in case you’re wondering why the Cake documentation doesn’t discuss it, or want to know how to Google up additional reading materials.