Cloud Run Functions에서 함수 정의를 찾으려면 소스 코드가 특정 구조를 따라야 합니다. 자세한 내용은 Cloud Run Functions 작성을 참고하세요.
PHP 구성
PHP 함수를 함수의 루트 디렉터리에 있는 php.ini 파일과 함께 구성합니다. 다음 코드 샘플에서 보여주는 것처럼 phpinfo() 함수를 사용하여 기존 PHP 구성 설정을 볼 수 있습니다.
use Psr\Http\Message\ServerRequestInterface;
function phpInfoDemo(ServerRequestInterface $request): string
{
// phpinfo() displays its output directly in the function's
// HTTP response, so we don't need to explicitly return it
//
// Note: we recommend deleting the deployed Cloud Function once you no
// longer need it, as phpinfo() may broadcast potential security issues.
phpinfo();
return '';
}
종속 항목 지정
composer.json이라는 프로젝트 파일에 종속 항목을 추가하여 함수의 종속 항목을 지정합니다. 자세한 내용은 PHP에서 종속 항목 지정을 참조하세요.
[[["이해하기 쉬움","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-05(UTC)"],[[["\u003cp\u003eCloud Run functions use \u003ccode\u003enginx\u003c/code\u003e and \u003ccode\u003ePHP-FPM\u003c/code\u003e to serve requests and run in an environment defined by the language version, known as the runtime.\u003c/p\u003e\n"],["\u003cp\u003eYou can select the preferred PHP runtime version for your function during deployment, with several versions supported and listed on the Runtime support page.\u003c/p\u003e\n"],["\u003cp\u003eFunctions can be deployed using the Google Cloud CLI with the \u003ccode\u003e--runtime\u003c/code\u003e parameter, or through the Google Cloud console.\u003c/p\u003e\n"],["\u003cp\u003ePHP functions can be prepared locally or directly in the Google Cloud console, and use the PHP Functions Framework library.\u003c/p\u003e\n"],["\u003cp\u003eDependencies for your PHP function are specified in a \u003ccode\u003ecomposer.json\u003c/code\u003e file, and configurations can be managed via a \u003ccode\u003ephp.ini\u003c/code\u003e file in the root directory.\u003c/p\u003e\n"]]],[],null,["# The PHP Runtime\n===============\n\nYour Cloud Run function runs in an environment consisting of an operating\nsystem version plus add-on packages, language support, and\nthe Functions Framework library that supports and invokes your function.\nThis environment is identified by the language version, and is known as the\nruntime.\n\nThese runtimes use `nginx` and `PHP-FPM` to serve requests. To learn more\nabout runtimes in general, and to learn which Ubuntu version each PHP runtime\nuses, see the [Cloud Run functions execution\nenvironment](/functions/1stgendocs/concepts/execution-environment#php).\n\nSelect your runtime\n-------------------\n\nCloud Run functions supports several versions of PHP, listed on the\n[Runtime support](/functions/1stgendocs/runtime-support#php) page. You can\nselect the preferred PHP runtime for your function during deployment. \n\n### gcloud\n\nIf you're using the Google Cloud CLI, specify the runtime\nby using the `--runtime` parameter. \u003cvar translate=\"no\"\u003eNAME\u003c/var\u003e specifies the\nfunction name. For example: \n\n```bash\ngcloud functions deploy NAME --no-gen2 --runtime php82 --trigger-http\n```\n\nFor more deployment parameters, see [Deploy a Cloud Run function](/functions/1stgendocs/deploy#basics).\n\n### Console\n\nIf you're using the Google Cloud console, see the [Google Cloud console\nquickstart](/functions/1stgendocs/console-quickstart-1st-gen) for\ndetailed instructions.\n\nFunction preparation\n--------------------\n\nYou can prepare a function directly from the Google Cloud console or write it on\nyour local machine and upload it. To prepare your local machine for PHP\ndevelopment, see [Using PHP on Google Cloud](/php/docs).\n\nThe library that invokes your function is the [PHP Functions\nFramework](https://github.com/GoogleCloudPlatform/functions-framework-php).\n| **Note:** The only type of [event-driven functions](/functions/1stgendocs/writing#types_of_cloud_functions) PHP supports are [CloudEvent functions](/functions/1stgendocs/writing#cloudevent_functions).\n\nSource code structure\n---------------------\n\nFor Cloud Run functions to find your function's definition, your\nsource code must follow a specific structure. See\n[Writing Cloud Run functions](/functions/1stgendocs/writing#structuring_source_code)\nfor more information.\n\nPHP Configuration\n-----------------\n\nYou configure your PHP function with a [`php.ini`\nfile](https://www.php.net/manual/en/configuration.file.php) in your function's\nroot directory. You can view existing PHP configuration settings with the\n[`phpinfo()`](https://www.php.net/manual/en/function.phpinfo.php) function as\nshown in the following code sample: \n\n \n use Psr\\Http\\Message\\ServerRequestInterface;\n\n function phpInfoDemo(ServerRequestInterface $request): string\n {\n // phpinfo() displays its output directly in the function's\n // HTTP response, so we don't need to explicitly return it\n //\n // Note: we recommend deleting the deployed Cloud Function once you no\n // longer need it, as phpinfo() may broadcast potential security issues.\n phpinfo();\n return '';\n }\n\nSpecifying dependencies\n-----------------------\n\nYou specify dependencies for your function by adding them to a project file\ncalled `composer.json`. For more information, see [Specifying dependencies in\nPHP](/functions/1stgendocs/writing/specifying-dependencies-php)."]]