PHP용 Google Cloud 클라이언트 라이브러리는 작성해야 하는 상용구 코드를 줄여주는 Google Cloud 서비스에 액세스하기 위한 클라이언트 라이브러리입니다. 이 라이브러리는 높은 수준의 이해하기 쉬운 API 추상화를 제공합니다. PHP 관용구를 포함하고 표준 라이브러리와 잘 작동하며 코드베이스와 더 긴밀하게 통합됩니다. 이 모든 기능들을 통해 중요한 코드를 만드는 데 더 많은 시간을 투자할 수 있습니다.
라이브러리를 로컬로 설치합니다.
composer require google/cloud
Google Cloud CLI를 사용하여 로컬에서 인증을 처리할 수 있습니다. 로컬 애플리케이션이 API 액세스를 위해 사용자 인증 정보를 일시적으로 사용하게 하려면 다음 명령어를 실행합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eComposer manages PHP dependencies in App Engine, automatically installing them upon deployment from a \u003ccode\u003ecomposer.json\u003c/code\u003e file located in your application's root directory.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003evendor/\u003c/code\u003e directory, where Composer installs dependencies, is automatically ignored by \u003ccode\u003e.gcloudignore\u003c/code\u003e to optimize deployment file sizes, and an \u003ccode\u003eautoload.php\u003c/code\u003e is created to load these dependencies automatically.\u003c/p\u003e\n"],["\u003cp\u003eYou can use the \u003ccode\u003egcloud app deploy --no-cache\u003c/code\u003e command to deploy uncached versions of dependencies, overriding App Engine's default caching behavior for faster build times.\u003c/p\u003e\n"],["\u003cp\u003eApp Engine supports various PHP web frameworks such as Symfony, Laravel, CodeIgniter, WordPress, Drupal, and Joomla!, and serves requests through \u003ccode\u003epublic/index.php\u003c/code\u003e or \u003ccode\u003eindex.php\u003c/code\u003e by default.\u003c/p\u003e\n"],["\u003cp\u003ePrivate repositories, like those on GitHub or Bitbucket, can be accessed by configuring them in \u003ccode\u003ecomposer.json\u003c/code\u003e and providing authentication credentials in an \u003ccode\u003eauth.json\u003c/code\u003e file.\u003c/p\u003e\n"]]],[],null,["# Specifying dependencies\n\n[Composer](https://getcomposer.org/) runs\nautomatically when you deploy a new version of your application. Simply add the\nfollowing line to the top of your PHP scripts to require the `autoload.php`\nfile: \n\n require_once __DIR__ . '/vendor/autoload.php';\n\nComposer adds the packages to your app's `vendor/` directory, where the\n`autoload.php` file is generated. The Composer autoloader automatically loads\nclasses installed by Composer without a `require` statement for each file.\n\nBy default, the `vendor/` directory is ignored in the generated\n[`.gcloudignore`](/sdk/gcloud/reference/topic/gcloudignore) file to reduce the\nnumber of files sent in deployment.\n\nYou can declare dependencies for PHP in a standard [`composer.json`](https://getcomposer.org/doc/01-basic-usage.md#composer-json-project-setup) file. For example: \n\n {\n \"require\": {\n \"google/cloud\": \"^0.72\"\n }\n }\n\nYou can use any Linux-compatible PHP package in App Engine. The runtime\nlooks for a [`composer.json`](https://getcomposer.org/doc/01-basic-usage.md#composer-json-project-setup) file in your application's source\ndirectory and uses [`composer`](https://getcomposer.org) to install any dependencies before\nstarting your application.\n\nScripts defined in your [`composer.json` file](https://getcomposer.org/doc/articles/scripts.md)\nwill not run when Composer can use a cached result.\n\n\nBy default, App Engine caches fetched dependencies to reduce build\ntimes. To install an uncached version of the dependency, use the command: \n\n gcloud app deploy --no-cache\n\n\u003cbr /\u003e\n\nInstalling and running locally\n------------------------------\n\nUse [composer](https://getcomposer.org) to install your dependencies locally: \n\n composer install\n\nTo pin your dependencies to their current version, commit the [`composer.lock`](https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file) file to your application.\n\n\u003cbr /\u003e\n\nYou can test your application using your web server of choice. To quickly run your application, you can use\n[PHP's built-in web server](http://php.net/manual/en/features.commandline.webserver.php).\n\n\nInstalling a web framework\n--------------------------\n\nBy default, App Engine serves all requests through the\n`public/index.php` or `index.php` file. A framework is not required, but is\nencouraged. You can use any web framework with App Engine, including the\nfollowing:\n\n- [Symfony](https://symfony.com/)\n- [Laravel](https://laravel.com/)\n- [CodeIgniter](https://www.codeigniter.com/)\n- [WordPress](https://wordpress.com/)\n- [Drupal](https://drupal.com/)\n- [Joomla!](https://www.joomla.com/)\n\nInstalling the Cloud Client Libraries\n-------------------------------------\n\nThe [Google Cloud Client Library for PHP](https://googleapis.github.io/google-cloud-php/#/)\nis a client library for accessing Google Cloud services that\nreduces the boilerplate code you have to write. The library provides high-level,\neasy to understand API abstractions. It embraces idioms of PHP,\nworks well with the standard library, and has tighter integration with your\ncodebase. All of this means you spend more time creating code that matters to\nyou.\n\n1. Install the library locally:\n\n composer require google/cloud\n\n2. You can handle authentication locally by using the [Google Cloud CLI](/sdk/docs).\n If you want your local application to temporarily use your own user credentials\n for API access, run:\n\n gcloud auth application-default login\n\n For details on configuring Cloud Client Libraries for PHP to handle authentication\n automatically, see [Authenticate to Cloud services using client libraries](/docs/authentication/client-libraries).\n\nUsing private repositories\n--------------------------\n\nTo use libraries in private repositories, you must complete the following tasks:\n\n- Configure the repository.\n- Give `composer` the secret to access the private repository.\n\nThe following example illustrates how to access a private repository in GitHub.\n\n1. Configure the repository in `composer.json` using `vcs` for the type:\n\n \"repositories\": [\n {\n \"type\": \"vcs\",\n \"url\": \"https://github.com/username/private_package\"\n }\n ]\n\n2. Create a file named `auth.json` in your project root directory:\n\n {\n \"github-oauth\": {\n \"github.com\": \"\u003cyour-github-auth-token\u003e\"\n }\n }\n\nYou can obtain the GitHub auth token from GitHub's administrative UI.\n\nHere is another example that illustrates how to access a private repository for\nBitbucket.\n\n1. Configure the repository in `composer.json` using `vcs` for the type:\n\n \"repositories\": [\n {\n \"type\": \"vcs\",\n \"url\": \"https://bitbucket.org/username/private_git\"\n }\n ]\n\n2. Create a file named `auth.json` in your project root directory:\n\n {\n \"bitbucket-oauth\": {\n \"bitbucket.org\": {\n \"consumer-key\": \"\u003cyour-oauth-consumer-key\u003e\",\n \"consumer-secret\": \"\u003cyour-oauth-consumer-secret\u003e\"\n }\n }\n }"]]