[[["이해하기 쉬움","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-03(UTC)"],[[["\u003cp\u003eComposer is used to manage dependencies in PHP, and it can be installed by downloading it and moving the \u003ccode\u003ecomposer.phar\u003c/code\u003e file to a directory in your system path.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ecomposer.json\u003c/code\u003e file, which can be created manually or via the \u003ccode\u003ecomposer init\u003c/code\u003e command, lists a project's dependencies.\u003c/p\u003e\n"],["\u003cp\u003eTo declare dependencies, add a \u003ccode\u003ecomposer.json\u003c/code\u003e file with the desired dependencies to your function code directory; a practical example, requiring PHP version 8.1 or higher and the Google Cloud Functions Framework version 1.1, is provided in the example.\u003c/p\u003e\n"],["\u003cp\u003eThe Functions Framework is a necessary dependency for Cloud Run functions, which can be added by using the command \u003ccode\u003ecomposer require google/cloud-functions-framework\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ecomposer update\u003c/code\u003e command is utilized to update the function's dependencies and the \u003ccode\u003ecomposer.lock\u003c/code\u003e file.\u003c/p\u003e\n"]]],[],null,["# Specify dependencies in PHP\n===========================\n\nYou use [Composer](https://getcomposer.org/) to\nmanage dependencies in PHP.\n\nInstalling Composer\n-------------------\n\nIf you don't already have Composer installed, you can\ndo so as follows:\n\n1. [Download Composer](https://getcomposer.org/download/) to any location you\n desire.\n\n2. Once it is downloaded, move the `composer.phar` file to a directory that is\n in your system path, for example:\n\n mv composer.phar /usr/local/bin/composer\n\nCreating a `composer.json` file\n-------------------------------\n\nThe `composer.json` file lists your function's dependencies. You can either\ncreate it by hand, or you can run the following command: \n\n composer init\n\nWhen you run this command, it interactively asks you to fill in the fields,\nwhile offering some smart defaults.\n\nDeclaring dependencies\n----------------------\n\nTo declare dependencies, add a `composer.json` file containing dependencies to your\nfunction code directory. In this example, we require the\n[Functions Framework](https://github.com/GoogleCloudPlatform/functions-framework-php)\nand add a `start` script: \n\n```php\n{\n \"require\": {\n \"php\": \"\u003e= 8.1\",\n \"google/cloud-functions-framework\": \"^1.1\"\n },\n \"scripts\": {\n \"start\": [\n \"Composer\\\\Config::disableProcessTimeout\",\n \"FUNCTION_TARGET=helloHttp php -S localhost:${PORT:-8080} vendor/google/cloud-functions-framework/router.php\"\n ]\n }\n}\n```\n\nNote that scripts defined in your\n[`composer.json` file](https://getcomposer.org/doc/articles/scripts.md)\nwill not run when Composer can use a cached result.\n\nAdd Functions Framework as a dependency\n---------------------------------------\n\nThe Cloud Run functions PHP runtime requires the Functions Framework to be an\nexplicit dependency. To add Functions Framework as a dependency, run the\nfollowing command in the directory containing your function code (this directory\nmust also contain the `composer.json` file): \n\n composer require google/cloud-functions-framework\n\nThis adds the Functions Framework to your `composer.json` and installs the\npackage in the `vendor/` directory.\n\n### `autoload.php` file\n\nOne of the files contained in your `vendor/` directory is `autoload.php`.\n\nAdd the following line to the top of your PHP scripts to require the\n`autoload.php` file, which automatically `require`s your function's other\ndependencies: \n\n require_once __DIR__ . '/vendor/autoload.php';\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\nUpdating dependencies\n---------------------\n\nTo update your function's dependencies and the `composer.lock` file, use the\n[`update` command](https://getcomposer.org/doc/03-cli.md#update-u): \n\n composer update\n\nThis resolves all dependencies of the project and writes their exact versions into\n`composer.lock`."]]