PHPackages                             marcandre/google-photos-library - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. marcandre/google-photos-library

ActiveLibrary[API Development](/categories/api)

marcandre/google-photos-library
===============================

Google Photos Library API Client Library for PHP

1.6.3.1(5y ago)06Apache-2.0PHPPHP ^5.5 || ^7.0 || ^8.0

Since Sep 4Pushed 5y agoCompare

[ Source](https://github.com/marcandreappel/php-photoslibrary)[ Packagist](https://packagist.org/packages/marcandre/google-photos-library)[ Docs](https://developers.google.com/photos)[ RSS](/packages/marcandre-google-photos-library/feed)WikiDiscussions main Synced yesterday

READMEChangelog (1)Dependencies (3)Versions (14)Used By (0)

Google Photos Library API PHP Client Library
============================================

[](#google-photos-library-api-php-client-library)

This repository contains the PHP client library for the [Google Photos Library API](https://developers.google.com/photos).

You can find [samples](#samples) for this library in the `samples` branch. See the samples section below.

Requirements and preparation
----------------------------

[](#requirements-and-preparation)

This library depends on [Composer](https://getcomposer.org/). If you don't have Composer installed on the command line as `composer`, follow the [Linux/unix/OS X](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx) or [Windows](https://getcomposer.org/doc/00-intro.md#installation-windows) installation guides.

- System requirements and dependencies can be found in [`composer.json`](composer.json)of this library. If you are not familiar with Composer, see [this page](https://getcomposer.org/doc/01-basic-usage.md) for more details.
- Your PHP installation must include the [`bcmath` extension](http://php.net/manual/en/book.bc.php).
- OAuth 2.0 credentials configured for your project as [described below](#set-up-your-oauth2-credentials-for-php).

Download the client library
---------------------------

[](#download-the-client-library)

Firstly, download the library, then set up OAuth 2.0 credentials to access the API. Next, you can follow the [samples](#samples) to see the client library in action.

Here are some ways to download this library:

MethodTarget Users[Using `composer require`](#using-composer-require)If you want to **use this library as a third-party library** for your projects and do not require example files.[Using `git clone`](#using-git-clone)If you want to **alter or contribute to this library** (for example, submitting a pull request) or want to **run example files**.[Downloading a compressed tarball](#downloading-a-compressed-tarball)If you only want to **run example files**.### Using composer require

[](#using-composer-require)

Follow the below steps to download this library as a third-party library for your projects. The library will be downloaded by [Composer](https://getcomposer.org/) and stored under the `vendor/` directory. Examples are not downloaded by this download method.

```
$ composer require google/photos-library

```

### Using git clone

[](#using-git-clone)

Use this method if you want to alter or contribute to this library (for example, submitting pull requests) or if you wish to try our samples. When you clone the repository, **all** files in this repository will be downloaded.

1. Run `git clone https://github.com/google/php-photoslibrary.git` at the command prompt.
2. You'll get a **php-photoslibrary** directory. Navigate to it by running `cd php-photoslibrary`.
3. Run `composer install` at the command prompt. This will install all dependencies needed for using the library.

### Downloading a compressed tarball

[](#downloading-a-compressed-tarball)

Use this method only if you want to try out the Google Photos Library API with this client library. The extracted directory of the tarball will contain only the samples from the `samples` branch.

1. On the [releases page](https://github.com/google/php-photoslibrary/releases), select a version you want to try. Then, under **Download**, select the tarball of your choice, for example, **php-photoslibrary-samples-vX.Y.Z.tar.gz**.
2. Extract your downloaded file to any location on your computer.
3. Navigate to the extracted directory (for example, **php-photoslibrary-samples-vX.Y.Z**).
4. Run `composer install` at the command prompt. This will install all dependencies needed for using the library and running examples.

Set up your OAuth2 credentials for PHP
--------------------------------------

[](#set-up-your-oauth2-credentials-for-php)

The Google Photos Library API uses [OAuth2](https://oauth.net/2/) as the authentication mechanism. Note that the Library API does not support service accounts.

To complete the “Enable the API” and “Configure OAuth2.0” steps in the below procedure, refer to the [get started guide in the developer documentation](https://developers.google.com/photos/library/guides/get-started-php)

This client library works with the [Google Auth Library for PHP](https://github.com/google/google-auth-library-php). Specify the client secret JSON file when initialising the library. Use the authentication credentials returned by the auth library when setting up the `PhotosLibraryClient`. See the file [sample/src/common/common.php](https://github.com/google/php-photoslibrary/tree/samples/src/common/common.php)for an example on how to do this.

Sample usage
------------

[](#sample-usage)

The best way to learn how to use this library is to [review the samples](#samples). The [developer documentation](https://developers.google.com/photos) also includes code snippets for this client library in PHP.

Once you have set up the dependencies and OAuth 2 credentials, you can access the API. Here's a short example that shows how to create a new album:

```
// [START sample_usage]
use Google\Auth\Credentials\UserRefreshCredentials;
use Google\Photos\Library\V1\PhotosLibraryClient;
use Google\Photos\Library\V1\PhotosLibraryResourceFactory;

try {
    // Use the OAuth flow provided by the Google API Client Auth library
    // to authenticate users. See the file /src/common/common.php in the samples for a complete
    // authentication example.
    $authCredentials = new UserRefreshCredentials( /* Add your scope, client secret and refresh token here */ );

    // Set up the Photos Library Client that interacts with the API
    $photosLibraryClient = new PhotosLibraryClient(['credentials' => $authCredentials]);

    // Create a new Album object with at title
    $newAlbum = PhotosLibraryResourceFactory::album("My Album");

    // Make the call to the Library API to create the new album
    $createdAlbum = $photosLibraryClient->createAlbum($newAlbum);

    // The creation call returns the ID of the new album
    $albumId = $createdAlbum->getId();
} catch (\Google\ApiCore\ApiException $exception) {
    // Error during album creation
} catch (\Google\ApiCore\ValidationException $e) {
    // Error during client creation
    echo $exception;
}
// [END sample_usage]
```

Samples
-------

[](#samples)

A few samples are included in the [`samples`](https://github.com/google/php-photoslibrary/tree/samples) directory. They show how to access media items, filter media, share albums, and upload files.

Reference Documentation
-----------------------

[](#reference-documentation)

PHPDoc for this library can be found in the [gh-pages](https://github.com/google/photos-library-php-lib/tree/gh-pages) branch of this repository. You can browse it online here:

General Google Photos Library API documentation can be found on our Google Developers site:

Coding Style
------------

[](#coding-style)

We use PSR-2 as a coding style standard. Assuming that you're at the root directory of your project, to check for coding style violations, run

```
vendor/bin/phpcs src --standard=phpcs_ruleset.xml -np

```

To automatically fix (fixable) coding style violations, run

```
vendor/bin/phpcbf src --standard=phpcs_ruleset.xml

```

Getting support
---------------

[](#getting-support)

For client library specific bug reports, feature requests, and patches, create an issue on the [issue tracker](https://github.com/google/php-photoslibrary/issues).

See the [support page](https://developers.google.com/photos/library/support/how-to-get-help)for any other API questions, bug reports, or feature requests.

Announcements and updates
-------------------------

[](#announcements-and-updates)

For general Google Photos Library API and client library updates and news, follow:

- [PHP client library release notes](https://github.com/google/php-photoslibrary/releases)
- [Google Photos Library API release notes](https://developers.google.com/photos/library/support/release-notes)

License
-------

[](#license)

Copyright 2018 Google LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

```
https://www.apache.org/licenses/LICENSE-2.0

```

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 60.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~84 days

Recently: every ~62 days

Total

12

Last Release

1885d ago

PHP version history (2 changes)v1.0.0PHP ^5.5 || ^7.0

1.6.3.1PHP ^5.5 || ^7.0 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4620c96e07f06cc88660ac5aa15f0933df05b9900b3fda902be7371f37574c91?d=identicon)[marc-andre](/maintainers/marc-andre)

---

Top Contributors

[![jfschmakeit](https://avatars.githubusercontent.com/u/8895424?v=4)](https://github.com/jfschmakeit "jfschmakeit (17 commits)")[![SignpostMarv](https://avatars.githubusercontent.com/u/304403?v=4)](https://github.com/SignpostMarv "SignpostMarv (8 commits)")[![marcandreappel](https://avatars.githubusercontent.com/u/946826?v=4)](https://github.com/marcandreappel "marcandreappel (2 commits)")[![laurenmanzo](https://avatars.githubusercontent.com/u/2498854?v=4)](https://github.com/laurenmanzo "laurenmanzo (1 commits)")

---

Tags

googlegoogle photos

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/marcandre-google-photos-library/health.svg)

```
[![Health](https://phpackages.com/badges/marcandre-google-photos-library/health.svg)](https://phpackages.com/packages/marcandre-google-photos-library)
```

###  Alternatives

[google/apiclient

Client library for Google APIs

9.8k191.4M997](/packages/google-apiclient)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)[google/apiclient-services

Client library for Google APIs

1.3k180.5M51](/packages/google-apiclient-services)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)[googleads/google-ads-php

Google Ads API client for PHP

3497.6M9](/packages/googleads-google-ads-php)[revolution/laravel-google-sheets

Google Sheets API v4

4483.1M6](/packages/revolution-laravel-google-sheets)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
