{"id":13405381,"url":"https://github.com/googleapis/google-cloud-php","last_synced_at":"2026-03-18T01:12:05.391Z","repository":{"id":37493339,"uuid":"43642389","full_name":"googleapis/google-cloud-php","owner":"googleapis","description":"Google Cloud Client Library for PHP","archived":false,"fork":false,"pushed_at":"2025-05-10T01:05:17.000Z","size":645039,"stargazers_count":1123,"open_issues_count":86,"forks_count":447,"subscribers_count":134,"default_branch":"main","last_synced_at":"2025-05-12T13:21:16.988Z","etag":null,"topics":["google-cloud-platform","php"],"latest_commit_sha":null,"homepage":"https://cloud.google.com/php/docs/reference","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/googleapis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":"Support/.OwlBot.yaml","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-10-04T16:09:46.000Z","updated_at":"2025-05-09T23:29:48.000Z","dependencies_parsed_at":"2022-07-09T09:46:15.258Z","dependency_job_id":"795de72e-df95-4993-b55b-64e05834b20d","html_url":"https://github.com/googleapis/google-cloud-php","commit_stats":{"total_commits":3714,"total_committers":127,"mean_commits":"29.244094488188978","dds":0.711900915455035,"last_synced_commit":"ae81a0b27a9a6f6fc919d98417b923709152ef2c"},"previous_names":[],"tags_count":324,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googleapis%2Fgoogle-cloud-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googleapis%2Fgoogle-cloud-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googleapis%2Fgoogle-cloud-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googleapis%2Fgoogle-cloud-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/googleapis","download_url":"https://codeload.github.com/googleapis/google-cloud-php/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745198,"owners_count":21957319,"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-cloud-platform","php"],"created_at":"2024-07-30T19:02:00.443Z","updated_at":"2026-01-17T17:43:31.336Z","avatar_url":"https://github.com/googleapis.png","language":"PHP","funding_links":[],"categories":["PHP","Interop \u0026 Model Serving","API Clients"],"sub_categories":["Tokenizers \u0026 Prompt Utilities","Utilities \u0026 Tools"],"readme":"# Google Cloud PHP Client\n\u003e Idiomatic PHP client for [Google Cloud Platform](https://cloud.google.com/) services.\n\n## CI Status\n\nView the [list of supported APIs and Services](https://cloud.google.com/php/docs/reference).\n\nIf you need support for other Google APIs, please check out the\n[Google APIs Client Library for PHP](https://github.com/google/google-api-php-client).\n\nWe recommend installing individual component packages. A list of available packages can be found on\n[Packagist](https://packagist.org/search/?q=google%2Fcloud-).\n\nFor example:\n```sh\n$ composer require google/cloud-storage\n$ composer require google/cloud-bigquery\n$ composer require google/cloud-datastore\n```\n\n## Quickstart\n\nIn this guide we'll focus on how to configure your client for local development using the Google\nCloud CLI (`gcloud`).\n\n### For local development:\n* Install the Google Cloud CLI.\n* Authenticate with `gcloud` to generate the credentials file.\n* Instantiate a client.\n\n### Installing the Google Cloud CLI\nIn order to generate our needed credentials file we need to authenticate to gcloud first.\nInstallation is handled differently depending on your platform. Here is a link to help you setup\nthe Google Cloud CLI:\n\nhttps://cloud.google.com/sdk/docs/install\n\n### Authenticate via the `gcloud` command\nOnce the Google Cloud CLI tools are installed it is required that we authenticate via the `gcloud`:\n```shell\n$ gcloud init\n$ gcloud auth application-default login\n```\n\nThis will create a local file in your system that the authentication library for our client will\nread in order to make requests to the apis with those credentials. This file is located in different\nplace depending on your system.\n\nWindows:\n```\n%APPDATA%\\gcloud\\application_default_credentials.json\n```\n\nLinux and MacOS:\n```\n$HOME/.config/gcloud/application_default_credentials.json\n```\n\nTo read more about Authentication, see [AUTHENTICATION.md](AUTHENTICATION.md)\n\n### Installing a client\nInstall the Google Translate client library with composer\n```sh\ncomposer install google/cloud-translate\n```\n**Note**: For this example, we are using the Google Translate client library. Check the\n[the complete list of packages](https://cloud.google.com/php/docs/reference/) to find your required\nlibrary.\n\n### Instantiating the client\nNow that we've authenticated and installed the client library, we can instantiate a client which will\ndetect the JSON file created by the gcloud CLI and use it to authenticate your requests:\n\n```php\nrequire_once 'vendor/autoload.php';\n\nuse Google\\Cloud\\Translate\\V3\\Client\\TranslationServiceClient;\nuse Google\\Cloud\\Translate\\V3\\TranslateTextRequest;\n\n// Instantiating the client gathers the credentials from the `application_default_credentials.json`\n$client = new TranslationServiceClient([]);\n\n$request = new TranslateTextRequest();\n$request-\u003esetParent('projects/\u003cYOUR_PROJECT_ID\u003e');\n$request-\u003esetTargetLanguageCode('en-US');\n$request-\u003esetContents(['こんにちは']);\n\n// The request will contain the authentication token based on the default credentials file\n$response = $client-\u003etranslateText($request);\n\nvar_dump($response-\u003egetTranslations()[0]);\n// {\n//     [\"translatedText\"]=\u003e\n//     string(5) \"Hello\"\n//     [\"detectedLanguageCode\"]=\u003e\n//     string(2) \"ja\"\n// }\n\n```\n\n### Authentication\n\n#### Note\nThis quickstart is built with local development in mind. The steps for deploying your project are\ndifferent depending on the environment you use. Here we provide some basic instruction in how to get\nstarted with deployment of your project:\n\n * For applications running elsewhere, authentication is usually accomplished using a Service\n   Account.\n\nFor more information on obtaining Service Account credentials see our\n[Authentication Guide](https://cloud.google.com/docs/authentication/production#manually). Set the\n`GOOGLE_APPLICATION_CREDENTIALS` environment variable pointing to your credentials file.\n\n#### Note:\nSome clients accept the `keyFilePath` and `keyFile` configuration options pointing to the credentials file:\n\n```php\nrequire 'vendor/autoload.php';\n\nuse Google\\Cloud\\Storage\\StorageClient;\n\n// Authenticate using a keyfile path\n$cloud = new StorageClient([\n    'keyFilePath' =\u003e 'path/to/keyfile.json'\n]);\n\n// Authenticate using keyfile data\n$cloud = new StorageClient([\n    'keyFile' =\u003e json_decode(file_get_contents('/path/to/keyfile.json'), true)\n]);\n```\nA list of clients that accept these parameters are:\n- [Bigtable](https://github.com/googleapis/google-cloud-php-bigtable)\n- [Spanner](https://github.com/googleapis/google-cloud-php-spanner)\n- [Firestore](https://github.com/googleapis/google-cloud-php-firestore)\n- [Datastore](https://github.com/googleapis/google-cloud-php-datastore)\n- [Pubsub](https://github.com/googleapis/google-cloud-php-pubsub)\n- [Debugger](https://github.com/googleapis/google-cloud-php-debugger)\n- [Logging](https://github.com/googleapis/google-cloud-php-logging)\n- [Translate](https://github.com/googleapis/google-cloud-php-translate)\n- [Bigquery](https://github.com/googleapis/google-cloud-php-bigquery)\n- [Storage](https://github.com/googleapis/google-cloud-php-storage)\n\nWe recommend to visit the Check the [client documentation][php-ref-docs] for the client library you're using for more in depth information.\n\n[php-ref-docs]: https://cloud.google.com/php/docs/reference\n\nIf you do not wish to embed your authentication information in your application code, you may also make use of [Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials).\n\n```php\nrequire 'vendor/autoload.php';\n\nuse Google\\Cloud\\Storage\\StorageClient;\n\nputenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/keyfile.json');\n\n$cloud = new StorageClient();\n```\n\nThe `GOOGLE_APPLICATION_CREDENTIALS` environment variable may be set in your server configuration.\n\n### Debugging\n\nPlease see our [Debugging guide](https://github.com/googleapis/google-cloud-php/blob/main/DEBUG.md)\nfor more information about the debugging tools.\n\n### gRPC and Protobuf\n\nMany clients in Google Cloud PHP offer support for gRPC, either as an option or a requirement. gRPC is a high-performance RPC framework created by Google. To use gRPC in PHP, you must install the gRPC PHP extension on your server. While not required, it is also recommended that you install the protobuf extension whenever using gRPC in production.\n\n```\n$ pecl install grpc\n$ pecl install protobuf\n```\n\n* [gRPC Installation Instructions](https://cloud.google.com/php/grpc)\n* [Protobuf Installation Instructions](https://cloud.google.com/php/grpc#installing_the_protobuf_runtime_library)\n\n## Caching Access Tokens\n\nBy default the library will use a simple in-memory caching implementation, however it is possible to override this behavior by passing a [PSR-6](http://www.php-fig.org/psr/psr-6/) caching implementation in to the desired client.\n\nThe following example takes advantage of [Symfony's Cache Component](https://github.com/symfony/cache).\n\n```php\nrequire 'vendor/autoload.php';\n\nuse Google\\Cloud\\Storage\\StorageClient;\nuse Symfony\\Component\\Cache\\Adapter\\ArrayAdapter;\n\n// Please take the proper precautions when storing your access tokens in a cache no matter the implementation.\n$cache = new ArrayAdapter();\n\n$storage = new StorageClient([\n    'authCache' =\u003e $cache\n]);\n```\n\nThis library provides a PSR-6 implementation with the SystemV shared memory at `Google\\Auth\\Cache\\SysVCacheItemPool`. This implementation is only available on *nix machines, but it's the one of the fastest implementations and you can share the cache among multiple processes. The following example shows how to use it.\n\n```php\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse Google\\Cloud\\Spanner\\SpannerClient;\nuse Google\\Auth\\Cache\\SysVCacheItemPool;\n\n$cache = new SysVCacheItemPool();\n\n$spanner = new SpannerClient([\n    'authCache' =\u003e $cache\n]);\n```\n\n## PHP Versions Supported\n\nAll client libraries support PHP 8.0 and above.\n\n## Versioning\n\nThis library follows [Semantic Versioning](http://semver.org/).\n\nPlease note it is currently under active development. Any release versioned\n0.x.y is subject to backwards incompatible changes at any time.\n\n**GA**: Libraries defined at a GA quality level are stable, and will not\nintroduce backwards-incompatible changes in any minor or patch releases. We will\naddress issues and requests with the highest priority. Please note, for any\ncomponents which include generated clients the GA guarantee will only apply to\nclients which interact with stable services. For example, in a component which\nhosts V1 and V1beta1 generated clients, the GA guarantee will only apply to the\nV1 client as the service it interacts with is considered stable.\n\n**Beta**: Libraries defined at a Beta quality level are expected to be mostly\nstable and we're working towards their release candidate. We will address issues\nand requests with a higher priority.\n\n## Contributing\n\nContributions to this library are always welcome and highly encouraged.\n\nSee [CONTRIBUTING](CONTRIBUTING.md) for more information on how to get started.\n\nThis repository is not an official support channel. If you have support questions,\nfile a support request through the normal Google support channels,\nor post questions on a forum such as [StackOverflow](http://stackoverflow.com/questions/tagged/google-cloud-platform+php).\n\n## License\n\nApache 2.0 - See [LICENSE](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogleapis%2Fgoogle-cloud-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogleapis%2Fgoogle-cloud-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogleapis%2Fgoogle-cloud-php/lists"}