Laravel PHP 8.1 on GCP APP engine deploying error

587 Views Asked by At

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
2

There are 2 best solutions below

3
Sathi Aiswarya On BEST ANSWER

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.

0
user6392101 On

Version handling in buildpack running behind the scene is inconsistent. Issue is discussed here https://github.com/GoogleCloudPlatform/buildpacks/issues/336

In general "php": "^8.1.*" should work.

If you are dealing with Laravel + App Engine you can check https://github.com/firevel/firevel