title: How to fix "Class not found" Error for the Google Sheets API?
body: <p>I am trying to set up a website that has google sheets API functionality, due to the constraints of the hosting service, I installed the API on my local computer with Composer before uploading everything onto the site. However, when I try creating the Google_Service_Sheets object, it says that the class cannot be found.</p>
  
  <p>I've tried recreating the autoload.php file, and also adding a seperate require function: </p>
  
  <pre class="lang-php prettyprint-override"><code>require_once "./googleapi/google-api-php-client-2.2.3/vendor/google/apiclient-services/src/Google/Service/Sheets.php";
  </code></pre>
  
  <p>Main code:</p>
  
  <pre class="lang-php prettyprint-override"><code>require_once $configs["googleapifilev2"];
  require_once "./googleapi/google-api-php-client-2.2.3/vendor/google/apiclient-services/src/Google/Service/Sheets.php";
  $client = new \Google_Client();
  $client-&gt;setApplicationName('test');
  $client-&gt;setScopes([\Google_Service_Sheets::SPREADSHEETS]);
  $client-&gt;setAccessType('offline');
  $client-&gt;setAuthConfig($configs["googlecredentials"]);
  $service = new \Google_Service_Sheets($client);
  </code></pre>
  
  <p>autoload.php code:</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  
  // autoload.php @generated by Composer
  
  require_once __DIR__ . '/composer/autoload_real.php';
  
  return ComposerAutoloaderInit68a7a3a3b2a74c49476ad55dd7b1c990::getLoader();
  </code></pre>
  
  <p>An error occurs only when I call the Google_Service_Sheets object, but not the Google_Client. </p>
  
  <p>Error message:</p>
  
  <pre><code>Fatal error: Uncaught Error: Class 'Google_Service_Sheets_Resource_Spreadsheets' not found in /storage/ssd3/963/10211963/public_html/googleapi/google-api-php-client-2.2.3/vendor/google/apiclient-services/src/Google/Service/Sheets.php:69
  Stack trace:
  #0 /storage/ssd3/963/10211963/public_html/twowvotingaction.php(56): Google_Service_Sheets-&gt;__construct(Object(Google_Client))
  #1 {main} thrown in /storage/ssd3/963/10211963/public_html/googleapi/google-api-php-client-2.2.3/vendor/google/apiclient-services/src/Google/Service/Sheets.php on line 69
  </code></pre>
  
  <p>(Related lines in the API sheets.php file):</p>
  
  <pre class="lang-php prettyprint-override"><code>  public function __construct(Google_Client $client, $rootUrl = null)
    {
      parent::__construct($client);
      $this-&gt;rootUrl = $rootUrl ?: 'https://sheets.googleapis.com/';
      $this-&gt;servicePath = '';
      $this-&gt;batchPath = 'batch';
      $this-&gt;version = 'v4';
      $this-&gt;serviceName = 'sheets';
  
      $this-&gt;spreadsheets = new Google_Service_Sheets_Resource_Spreadsheets( //Line 69
          $this,
          $this-&gt;serviceName,
          'spreadsheets',
  </code></pre>