Click here to see your recently viewed pages and most viewed pages.
Hide

Installation

This page contains information about installing the Google APIs Client Library for PHP.

Requirements

  • PHP version 5.2.1 or greater.
  • The JSON PHP extension.
  • Support for a writeable file system or Memcache.
  • cURL for the cURL IO method, or allow_url_fopen enabled for the Streams IO method.

Obtaining the client library

There are two options for obtaining the files for the client library.

Using Composer

You can install the library by adding it as a dependency to your composer.json.

"require": {
  "google/apiclient": "1.0.*@beta"
}
    

Cloning from GitHub

The library is available on GitHub. You can clone it into a local repository with the git clone command.

git clone https://github.com/google/google-api-php-client.git .
    

What to do with the files

After obtaining the files, ensure they are available to your code. If you're using Composer, this is handled for you automatically. If not, you will need to add the location of the src/ directory inside the client library to the include_path, so that the PHP runtime can find the files. You can do this either via php.ini, or dynamically at runtime.

Setting include_path in PHP.ini

The best way to define the location of library files is to add it to the path in the PHP.ini configuration file.

include_path = ".:/usr/local/lib/php:/path/to/google-api-php-client/src"
    

Setting include_path dynamically in your code

Alternatively, you can set the same ini directive dynamically in your code.

set_include_path(get_include_path() . PATH_SEPARATOR . '/path/to/google-api-php-client/src');