Search code examples
phplaravelgoogle-cloud-platformgoogle-app-engine-php

Laravel PHP 8.1 on GCP APP engine deploying error


I use cloud build trigger to build my first APP Engine, but I keep receiving following message.

"There is no PHP runtime version specified in composer.json, or we don't support the version you specified. Google App Engine uses the latest 7.3.x version."

I already tried following settings but still don't work.

composer.json:

"require": {
    "php": "^8.1",

In app.yalm:

runtime: php81

In cloudbuild.yaml:

steps:
  - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
    entrypoint: 'bash'
    args:
        - '-c'
        - |
          gcloud config set app/cloud_build_timeout 3600 \
          && gcloud app deploy -q --promote -v=$BUILD_ID \
          --project=$PROJECT_ID

timeout: '3600s'

And I tried following commend:

composer require php 8.1.*

composer clearcache

composer update

Solution

  • As mentioned in this document

    By default, the PHP runtime uses PHP 7.3, but you should explicitly declare your PHP version in the composer.json file to prevent your application from being automatically upgraded when a new version of PHP becomes available. The PHP version 7.2.* is also supported.

    {
        "require": {
            "php": "7.3.*"
        }
    }
    

    Note :When you specify the PHP version, use the format MAJOR.MINOR.* and do not specify the release version. The PHP runtime is regularly updated to the latest release version and only supports one release version at a time, so specifying a release version can cause an error.