Google actually has a guide for this. But when I was following along, I ran into some issues with the deploy process because certain composer packages require PHP>=8.0
.
Finally…I have figured out how to do this now without running into build errors.
Currently Supported PHP Versions
Unfortunately, the App Engine Flexible environment does not currently support PHP 8.0+. More specifically, the Flexible environment only supports 7.2 and 7.3. Whereas the Standard environment supports PHP 5 and 7. Unfortunately, 7.3 is no longer an official PHP supported version as of 2021-12-06.
There is a ticket for PHP 8.0 support (please go +1 this for more visibility), although it has been open for two years.
Visit the App Engine docs on PHP for more information.
Locking the PHP Version for Composer
When following Google’s guide for WordPress on the App Engine Flexible environment, it does not mention anything about PHP versions, supported or otherwise. Even on their Supported PHP versions page, it says that “the Google Cloud Client Libraries for PHP are compatible with at least the three most recent, major PHP releases.” But Google App Engine Flexible still only supports 7.2/7.3.
If you attempt to deploy an app, you will get composer build errors referencing packages that require PHP>=8.0
.
Ensure that you have the required PHP version installed (e.g. 7.3), and lock composer to that version.
composer require -W php 7.3.*
The --with-all-dependencies (-W)
option allows upgrades, downgrades, and removals for packages currently locked to specific versions. Or alternatively, you can just remove the composer.lock file and re-install packages using the fixed PHP version.
Otherwise, if you have previously installed composer packages using PHP >= 8.0, then you may see build errors like this:
Problem 1
- Root composer.json requires ramsey/uuid ^3.0, found ramsey/uuid[3.0.0, ..., 3.9.6] but the package is fixed to 4.3.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
Problem 2
- ramsey/uuid 4.3.0 requires php ^8.0 -> your php version (7.3.33) does not satisfy that requirement.
- google/cloud v0.175.0 requires ramsey/uuid ^3.0|^4.0 -> satisfiable by ramsey/uuid[4.3.0].
- google/cloud is locked to version v0.175.0 and an update of this package was not requested.
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
Enable the Cloud Scheduler API
Something else Google doesn’t mention in their guide. Although, this may be another “implied knowledge” thing. While attempting to deploy using the correct PHP version, I got stuck on this:
Updating config [cron]...API [cloudscheduler.googleapis.com] not enabled on project [xxxxxxxxxxxxx]. Would you like to enable
Updating config [cron]...⠧
If this happens, abort the deployment, and go back to the GCP console and enable the Cloud Scheduler API.
After enabling, try deploying your app again. It should work this time.
Leave a Reply