diff --git a/.github/workflows/buildpack-integration-test.yml b/.github/workflows/buildpack-integration-test.yml index 5a748c62..c0242363 100644 --- a/.github/workflows/buildpack-integration-test.yml +++ b/.github/workflows/buildpack-integration-test.yml @@ -35,7 +35,7 @@ jobs: output-file: 'vendor/bin/function_output.json' builder-runtime: 'php82' builder-runtime-version: '">=8.2,<8.3"' - php82-buildpack-test: + php83-buildpack-test: if: github.event.pull_request.head.repo.full_name == github.repository uses: GoogleCloudPlatform/functions-framework-conformance/.github/workflows/buildpack-integration-test.yml@main with: @@ -46,4 +46,4 @@ jobs: prerun: 'tests/conformance/prerun.sh ${{ github.sha }}' output-file: 'vendor/bin/function_output.json' builder-runtime: 'php83' - builder-runtime-version: '">=8.3,<8.4"' \ No newline at end of file + builder-runtime-version: '">=8.3,<8.4"' diff --git a/.github/workflows/conformance.yml b/.github/workflows/conformance.yml index 51c0ef72..ea1ea2db 100644 --- a/.github/workflows/conformance.yml +++ b/.github/workflows/conformance.yml @@ -18,7 +18,7 @@ jobs: name: PHP ${{ matrix.php-version }} Conformance Test steps: - name: Harden Runner - uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 with: egress-policy: block allowed-endpoints: > @@ -31,10 +31,10 @@ jobs: storage.googleapis.com:443 - name: Checkout code - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Setup PHP ${{ matrix.php-version }} - uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2 + uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # v2 with: php-version: ${{ matrix.php-version }} @@ -46,7 +46,7 @@ jobs: command: composer install - name: Setup Go - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 with: go-version: '1.20' diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 5ee3b533..e3d6a018 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Harden Runner - uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 with: disable-sudo: true egress-policy: block @@ -26,6 +26,6 @@ jobs: github.com:443 - name: 'Checkout Repository' - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: 'Dependency Review' - uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4.3.4 + uses: actions/dependency-review-action@3b139cfc5fae8b618d3eae3675e383bb1769c019 # v4.5.0 diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 69d8580a..3c40baf4 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -12,15 +12,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Harden Runner - uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 with: disable-sudo: true egress-policy: block allowed-endpoints: > github.com:443 - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: PHP-CS-Fixer - uses: docker://oskarstark/php-cs-fixer-ga:latest@sha256:0c86f441e2141a32bfb54deebb9d25ae6dd54dbca64d95f9eec0c92b0c3dcad1 + uses: docker://oskarstark/php-cs-fixer-ga:latest@sha256:a4dc1c964e0f4118aef8ba80ee329157cf1e857e70f4cd1efdc22856887c1d14 with: args: . --diff --dry-run diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 5508984c..894ecc52 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -25,7 +25,7 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 with: disable-sudo: true egress-policy: block @@ -42,7 +42,7 @@ jobs: www.bestpractices.dev:443 - name: "Checkout code" - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false @@ -59,6 +59,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@8214744c546c1e5c8f03dde8fab3a7353211988d # v3.26.7 + uses: github/codeql-action/upload-sarif@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0 with: sarif_file: results.sarif diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 967156b2..6e5dd50a 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -17,7 +17,7 @@ jobs: name: PHP ${{ matrix.php-versions }} Unit Test steps: - name: Harden Runner - uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 with: egress-policy: block allowed-endpoints: > @@ -36,9 +36,9 @@ jobs: *.githubusercontent.com:443 - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Uses PHP ${{ matrix.php-versions }} - uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2 + uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # v2 with: php-version: ${{ matrix.php-versions }} - name: Install Dependencies diff --git a/.gitignore b/.gitignore index 124e0b88..1f6ab2aa 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ vendor/ .idea/ /.php_cs.cache *.iml -.phpunit.result.cache \ No newline at end of file +.phpunit.result.cache +.php-cs-fixer.cache diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fb0677e..4b7c8114 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## [1.4.2](https://github.com/GoogleCloudPlatform/functions-framework-php/compare/v1.4.1...v1.4.2) (2025-01-03) + + +### Bug Fixes + +* remove [@run](https://github.com/run)InSeparateProcess from EmitterTest ([#211](https://github.com/GoogleCloudPlatform/functions-framework-php/issues/211)) ([d72892a](https://github.com/GoogleCloudPlatform/functions-framework-php/commit/d72892a711b553b28d46f7aa18a8de9f2d511c16)) +* update source files with PHP-CS-Fixer ([#212](https://github.com/GoogleCloudPlatform/functions-framework-php/issues/212)) ([c845547](https://github.com/GoogleCloudPlatform/functions-framework-php/commit/c8455472e1227d20c816f2693eab0eff58528d0a)) + + +### Miscellaneous Chores + +* **deps:** update all non-major dependencies ([#202](https://github.com/GoogleCloudPlatform/functions-framework-php/issues/202)) ([9e83219](https://github.com/GoogleCloudPlatform/functions-framework-php/commit/9e832194e6b4f80999d0373bccdeb477ed28efbb)) +* **deps:** update all non-major dependencies ([#206](https://github.com/GoogleCloudPlatform/functions-framework-php/issues/206)) ([f79172d](https://github.com/GoogleCloudPlatform/functions-framework-php/commit/f79172d71f498bbffc4ff86a6cee6186dc69a9f4)) +* **deps:** update all non-major dependencies ([#215](https://github.com/GoogleCloudPlatform/functions-framework-php/issues/215)) ([0eb7d07](https://github.com/GoogleCloudPlatform/functions-framework-php/commit/0eb7d077f07daa58540c55233c38b37b4dcf8c52)) +* **deps:** update oskarstark/php-cs-fixer-ga:latest docker digest to a4dc1c9 ([#213](https://github.com/GoogleCloudPlatform/functions-framework-php/issues/213)) ([3725df5](https://github.com/GoogleCloudPlatform/functions-framework-php/commit/3725df5d1d41daf6c5e8734c500df9bf240696e0)) +* **deps:** update oskarstark/php-cs-fixer-ga:latest docker digest to b9b4d3b ([#205](https://github.com/GoogleCloudPlatform/functions-framework-php/issues/205)) ([99880ee](https://github.com/GoogleCloudPlatform/functions-framework-php/commit/99880eeaa546c5b4ace83f288c5100003456bd61)) +* **deps:** update shivammathur/setup-php digest to 9e72090 ([#214](https://github.com/GoogleCloudPlatform/functions-framework-php/issues/214)) ([dea0e80](https://github.com/GoogleCloudPlatform/functions-framework-php/commit/dea0e804a813ffc26876bb0e7cc78e2db9516a8c)) + ## [1.4.1](https://github.com/GoogleCloudPlatform/functions-framework-php/compare/v1.4.0...v1.4.1) (2024-10-02) diff --git a/README.md b/README.md index 9da692d4..6c8c1a89 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ The Functions Framework lets you write lightweight functions that run in many different environments, including: * Your local development machine -* [Cloud Run and Cloud Run on GKE](https://cloud.google.com/run/) * [Knative](https://github.com/knative/)-based environments The framework allows you to go from: @@ -110,102 +109,16 @@ curl localhost:8080 # Output: Hello World from a PHP HTTP function! ``` -## Run your function on Google Cloud Functions +## Run your function on Google Cloud Run Functions **NOTE**: For an extensive list of samples, see the [PHP functions samples][functions-samples] and the [official how-to guides][functions-how-to]. -Follow the steps below to deploy to Google Cloud Functions. More information -on function deployment is available in the -[GCF documentation](https://cloud.google.com/functions/docs/deploying). +Follow the [Cloud Run function quickstart](https://cloud.google.com/run/docs/quickstarts/functions/deploy-functions-gcloud#php) for PHP to learn how to deploy a function to Cloud Run. -To run your function on Cloud Functions, first you must have the [gcloud SDK][gcloud] installed and [authenticated][gcloud-auth]. +## Run your function as a container in Cloud Run -Make sure your source file (which defines your function) is called -`index.php`. The Functions Framework lets you choose a function source file, -but Cloud Functions currently uses the default of `index.php`. - -Decide _which_ function in the source file to invoke, that is, the name that you -used when writing the function. This is called the **target**. - -Choose a Cloud Functions **name** for your function. The **name** identifies -this function deployment (e.g. in the cloud console) and is also part of the -function's default URL. (Note: the **name** and the **target** do not have to -be the same value.) - -Then, from the directory containing your function source, issue the gcloud command to deploy: - -```sh -gcloud functions deploy $YOUR_FUNCTION_NAME \ - --runtime=php74 \ - --entry-point=$YOUR_FUNCTION_TARGET \ - --trigger-http -``` - -The `--entry-point` flag can be omitted if the **target** has the same value -as the **name**. - -If your function handles events rather than HTTP requests, you'll need to -replace `--trigger-http` with a different trigger. For details, see the -[reference documentation](https://cloud.google.com/sdk/gcloud/reference/functions/deploy) -for `gcloud functions deploy`. - -To update your deployment, just redeploy using the same function **name**. -Configuration flags are not required. - -## Run your function in Cloud Run - -To run your function in Cloud Run, first you must have the [gcloud SDK][gcloud] installed and [authenticated][gcloud-auth]. - -Additionally, you need to have a Google Cloud project ID for the -[Google Cloud Project][gcp-project] you want to use. - -After completing the steps under **Installation** and **Define your Function**, build the container using the example `Dockerfile`. This Dockerfile is -built on top of the [App Engine runtime for PHP 7.4][gae-php7], but you can use -any container you want as long as your application listens on **Port 8080**. - -```sh -docker build . \ - -f vendor/google/cloud-functions-framework/examples/hello/Dockerfile \ - -t gcr.io/$GCLOUD_PROJECT/my-cloud-function -``` - -> **NOTE**: Be sure to replace `$GCLOUD_PROJECT` with your Google Cloud project -ID, or set the environment variable using `export GCLOUD_PROJECT="some-project-id"`. - -Next, push your image to [Google Container Registry](https://cloud.google.com/container-registry). This will allow you to deploy it directly from Cloud Run. - -```sh -docker push gcr.io/$GCLOUD_PROJECT/my-cloud-function -``` - -Finally, use the `gcloud` command-line tool to deploy to Cloud Run: - -```sh -gcloud run deploy my-cloud-function \ - --image=gcr.io/$GCLOUD_PROJECT/my-cloud-function \ - --platform managed \ - --set-env-vars "FUNCTION_TARGET=helloHttp" \ - --allow-unauthenticated \ - --region $CLOUD_RUN_REGION \ - --project $GCLOUD_PROJECT -``` - -> **NOTE**: Be sure to replace `$CLOUD_RUN_REGION` with the -[correct region][cloud-run-regions] for your Cloud Run instance, for example -`us-central1`. - -After your instance deploys, you can access it at the URL provided, or view it -in the [Cloud Console][cloud-run-console]. - -[functions-samples]: https://github.com/GoogleCloudPlatform/php-docs-samples/tree/main/functions -[functions-how-to]: https://cloud.google.com/functions/docs/how-to -[gcloud]: https://cloud.google.com/sdk/gcloud/ -[gcloud-auth]: https://cloud.google.com/sdk/docs/authorizing -[gcp-project]: https://cloud.google.com/resource-manager/docs/creating-managing-projects -[gae-php7]: https://cloud.google.com/appengine/docs/standard/php7/runtime -[cloud-run-regions]: https://cloud.google.com/run/docs/locations -[cloud-run-console]: https://console.cloud.google.com/run +You can manually build your function as a container and deploy it into Cloud Run. Follow the [Cloud Run instructions for building a function](https://cloud.google.com/run/docs/building/functions) for complete instructions. ## Use CloudEvents diff --git a/examples/hello/index.php b/examples/hello/index.php index e82e139a..bc4d0987 100644 --- a/examples/hello/index.php +++ b/examples/hello/index.php @@ -1,4 +1,5 @@