{"id":13405234,"url":"https://github.com/google/php-photoslibrary","last_synced_at":"2026-01-11T16:52:01.732Z","repository":{"id":46726519,"uuid":"147293112","full_name":"google/php-photoslibrary","owner":"google","description":"PHP client library for the Google Photos Library API","archived":false,"fork":false,"pushed_at":"2021-10-01T03:42:48.000Z","size":2814,"stargazers_count":89,"open_issues_count":13,"forks_count":32,"subscribers_count":15,"default_branch":"main","last_synced_at":"2024-10-01T18:18:48.900Z","etag":null,"topics":["google","google-photos","php"],"latest_commit_sha":null,"homepage":"http://developers.google.com/photos","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/google.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-04T05:34:19.000Z","updated_at":"2024-09-12T18:49:50.000Z","dependencies_parsed_at":"2022-09-07T06:22:02.888Z","dependency_job_id":null,"html_url":"https://github.com/google/php-photoslibrary","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fphp-photoslibrary","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fphp-photoslibrary/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fphp-photoslibrary/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fphp-photoslibrary/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/google","download_url":"https://codeload.github.com/google/php-photoslibrary/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221454077,"owners_count":16824598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["google","google-photos","php"],"created_at":"2024-07-30T19:01:57.706Z","updated_at":"2024-10-25T19:31:53.411Z","avatar_url":"https://github.com/google.png","language":"PHP","readme":"# Google Photos Library API PHP Client Library\n\nThis repository contains the PHP client library for the [Google Photos Library\nAPI](https://developers.google.com/photos).\n\nYou can find [samples](#samples) for this library in the `samples` branch. See the samples section below.\n\n## Requirements and preparation\nThis library depends on [Composer](https://getcomposer.org/). If you don't have Composer installed\non the command line as `composer`, follow the \n[Linux/unix/OS X](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx) or \n[Windows](https://getcomposer.org/doc/00-intro.md#installation-windows) installation guides.\n\n*   System requirements and dependencies can be found in [`composer.json`](composer.json)\n    of this library. If you are not familiar with Composer, see \n    [this page](https://getcomposer.org/doc/01-basic-usage.md) for more details.\n*   Your PHP installation must include the [`bcmath` extension](http://php.net/manual/en/book.bc.php).\n*   OAuth 2.0 credentials configured for your project as [described below](#set-up-your-oauth2-credentials-for-php).\n\n\n## Download the client library\n\nFirstly, download the library, then set up OAuth 2.0 credentials to access the API.\nNext, you can follow the [samples](#samples) to see the client library in action.\n\nHere are some ways to download this library:\n\n| Method                                                                | Target Users                                                                                                                  |\n|-----------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| [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.          |\n| [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**. |\n| [Downloading a compressed tarball](#downloading-a-compressed-tarball) | If you only want to **run example files**.                                                                                 |\n\n### Using composer require\n\nFollow the below steps to download this library as a third-party library for your projects.\nThe library will be downloaded by [Composer](https://getcomposer.org/) and stored under the\n`vendor/` directory.\nExamples are not downloaded by this download method.\n\n\n```\n$ composer require google/photos-library\n```\n\n\n\n### Using git clone\n\nUse this method if you want to alter or contribute to this library (for example, submitting pull\nrequests) or if you wish to try our samples. When you clone the repository, **all** files in this\nrepository will be downloaded.\n\n1.  Run `git clone https://github.com/google/php-photoslibrary.git` at\n    the command prompt.\n1.  You'll get a **php-photoslibrary** directory. Navigate to it by running\n    `cd php-photoslibrary`.\n1.  Run `composer install` at the command prompt. This will install all\n    dependencies needed for using the library.\n\n### Downloading a compressed tarball\n\nUse this method only if you want to try out the Google Photos Library API with this client library.\nThe extracted directory of the tarball will contain only the samples from the `samples` branch.\n\n1.  On the [releases page](https://github.com/google/php-photoslibrary/releases),\n    select a version you want to try. Then, under **Download**, select the tarball\n    of your choice, for example, **php-photoslibrary-samples-vX.Y.Z.tar.gz**.\n1.  Extract your downloaded file to any location on your computer.\n1.  Navigate to the extracted directory (for example, **php-photoslibrary-samples-vX.Y.Z**).\n1.  Run `composer install` at the command prompt. This will install all dependencies\n    needed for using the library and running examples.\n\n\n## Set up your OAuth2 credentials for PHP\n\nThe Google Photos Library API uses [OAuth2](https://oauth.net/2/) as the\nauthentication mechanism. Note that the Library API does not support service accounts.\n\nTo complete the “Enable the API” and “Configure OAuth2.0” steps in the below procedure, refer to\nthe [get started guide in the developer documentation](https://developers.google.com/photos/library/guides/get-started-php)\n\nThis client library works with the [Google Auth Library for PHP](https://github.com/google/google-auth-library-php).\nSpecify the client secret JSON file when initialising the library.\nUse the authentication credentials returned by the auth library when setting up the\n`PhotosLibraryClient`. See the file [sample/src/common/common.php](https://github.com/google/php-photoslibrary/tree/samples/src/common/common.php)\nfor an example on how to do this.\n\n## Sample usage\nThe best way to learn how to use this library is to [review the samples](#samples).\nThe [developer documentation](https://developers.google.com/photos) also includes\ncode snippets for this client library in PHP.\n\nOnce you have set up the dependencies and OAuth 2 credentials, you can access\nthe API.\nHere's a short example that shows how to create a new album:\n```php\n// [START sample_usage]\nuse Google\\Auth\\Credentials\\UserRefreshCredentials;\nuse Google\\Photos\\Library\\V1\\PhotosLibraryClient;\nuse Google\\Photos\\Library\\V1\\PhotosLibraryResourceFactory;\n\ntry {\n    // Use the OAuth flow provided by the Google API Client Auth library\n    // to authenticate users. See the file /src/common/common.php in the samples for a complete\n    // authentication example.\n    $authCredentials = new UserRefreshCredentials( /* Add your scope, client secret and refresh token here */ );\n\n    // Set up the Photos Library Client that interacts with the API\n    $photosLibraryClient = new PhotosLibraryClient(['credentials' =\u003e $authCredentials]);\n\n    // Create a new Album object with at title\n    $newAlbum = PhotosLibraryResourceFactory::album(\"My Album\");\n\n    // Make the call to the Library API to create the new album\n    $createdAlbum = $photosLibraryClient-\u003ecreateAlbum($newAlbum);\n\n    // The creation call returns the ID of the new album\n    $albumId = $createdAlbum-\u003egetId();\n} catch (\\Google\\ApiCore\\ApiException $exception) {\n    // Error during album creation\n} catch (\\Google\\ApiCore\\ValidationException $e) {\n    // Error during client creation\n    echo $exception;\n}\n// [END sample_usage]\n```\n\n## Retry configuration\n\nThe default retry configuration follows the [AIP guidance](https://google.aip.dev/194) for\nretrying API requests, which is configured in\n[`photos_library_client_config.json`](src/Google/Photos/Library/V1/resources/photos_library_client_config.json).\n\nThis client library uses the [Google gax-php](https://github.com/googleapis/gax-php) library to\nmake calls. See its reference documentation for `\\Google\\ApiCore\\RetrySettings` that describes\nhow to customize the retry configuration for individual invocations, for a group of API calls or\nfor an entire client instance.\n\nMedia byte uploads made using `PhotosLibraryClient -\u003e upload (..)` that have failed are not\nattempted again unless a retry configuration has been specified. Customize the\n`UploadRetrySettings` to configure the retry behaviour. Here's an example that shows how to change\nthe retry behaviour for byte uploads for a client instance:\n\n```php\n$uploadRetrySettings = [\n    'initialRetryDelayMillis' =\u003e 1000, // 1 second\n    'retryDelayMultiplier' =\u003e 1.3,\n    'maxRetryDelayMillis' =\u003e 10000, // 10 seconds\n    'singleTimeoutMillis' =\u003e 900000, // 15 minutes\n    'maxNumRetries' =\u003e 5,\n    'retryableCodes' =\u003e [ApiStatus::DEADLINE_EXCEEDED, ApiStatus::UNAVAILABLE],\n    'retryableExceptions' =\u003e []\n];\n\n$photosLibraryClient = new PhotosLibraryClient([\n    'credentials' =\u003e $myCredentials,\n    'uploadRetrySettings' =\u003e $uploadRetrySettings\n]);\n```\n\n## Samples\nA few samples are included in the [`samples`](https://github.com/google/php-photoslibrary/tree/samples) directory.\nThey show how to access media items, filter media, share albums, and upload files.\n\n## Reference Documentation\n\nPHPDoc 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.\nYou can browse it online here: [https://google.github.io/php-photoslibrary/index.html](https://google.github.io/php-photoslibrary/index.html)\n\nGeneral Google Photos Library API documentation can be found on our Google Developers\nsite: https://developers.google.com/photos\n\n## Coding Style\n\nWe use PSR-2 as a coding style standard. Assuming that you're at the root\ndirectory of your project, to check for coding style violations,\nrun\n\n```shell\n./vendor/bin/phpcs --standard=phpcs_ruleset.xml -np\n```\n\nTo automatically fix (fixable) coding style violations, run\n\n```shell\n./vendor/bin/phpcbf --standard=phpcs_ruleset.xml\n```\n\n## Getting support\n\nFor client library specific bug reports, feature requests, and patches,\ncreate an issue on the [issue\ntracker](https://github.com/google/php-photoslibrary/issues).\n\nSee the [support page](https://developers.google.com/photos/library/support/how-to-get-help)\nfor any other API questions, bug reports, or feature requests.\n\n## Announcements and updates\n\nFor general Google Photos Library API and client library updates and news, follow:\n\n*   [PHP client library release notes](https://github.com/google/php-photoslibrary/releases)\n*   [Google Photos Library API release notes](https://developers.google.com/photos/library/support/release-notes)\n\n## License\n\nCopyright 2018 Google LLC\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fphp-photoslibrary","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogle%2Fphp-photoslibrary","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fphp-photoslibrary/lists"}