Learn how to migrate your PHP 5.5 application to the PHP 7 runtime on the App Engine standard environment.
Compatibility issues between PHP 5.5 and PHP 7
The official PHP documentation provides information on migrating from different PHP versions:
- Migrating from PHP 5.5.x to PHP 5.6.x
- Migrating from PHP 5.6.x to PHP 7.0.x
- Migrating from PHP 7.0.x to PHP 7.1.x
- Migrating from PHP 7.1.x to PHP 7.2.x
- Migrating from PHP 7.2.x to PHP 7.3.x
- Migrating from PHP 7.3.x to PHP 7.4.x
Migrating your app.yaml
file
You must place a front controller to handle all routing in your application. For more information, see Application startup.
The PHP 7 runtime does not allow the script
handler element to be
customized. The only valid value is auto
, because all traffic is served using
the entrypoint command. All non-static URL handlers must include script: auto
to deploy successfully.
The behavior of some elements in the app.yaml
configuration file has been
modified:
Element | Change type | Description |
---|---|---|
entrypoint | Added | Optionally, use this field to specify the command that will run when your app starts. |
threadsafe | Deprecated | All applications are presumed to be threadsafe, meaning an instance can handle multiple requests at the same time. |
api_version | Deprecated | Previously required but not needed in the PHP 7 runtime. |
application_readable | Deprecated | |
builtins | Deprecated | |
libraries | Deprecated | Arbitrary third
party dependencies can be installed using a composer.json
metadata file. |
handlers | Modified |
|
If you use of any of the deprecated fields, there will be an error on app deployment.
For more information, see the app.yaml
reference.
Reduced runtime restrictions
The PHP 7 runtime has fewer restrictions compared to the PHP 5.5 runtime.
- Install third-party dependencies.
- The runtime includes a full filesystem.
- Create background threads or processes that live beyond the scope of the request while the instance runs.
- Use the Google Cloud Client Library for PHP to integrate apps with other Google Cloud services. For more information, see the Installing the Google Cloud Client Library page.
For more information, see the PHP 7 runtime environment documentation.
Migrating from the App Engine PHP SDK
The PHP 7 runtime does not support the App Engine-specific APIs. Most of the functionality provided by these APIs is now provided by the Cloud SDK client library:
- App Engine Blobstore API support is not provided. Use Cloud Storage
through the
google/cloud-storage
client library. To get started, see the Cloud Storage Client Libraries page. - Datastore is accessible through the google/cloud-datastore client library. To get started see the Datastore Client Libraries page.
App Engine Images API support is not provided. For manipulating and processing images, we recommend imgix. If you require a free tier, use Rethumb.
To store and serve your images, use Cloud Storage through the
google/cloud-storage
client library. To get started, see the Cloud Storage Client Libraries page.App Engine Mail API support is not provided. To send email, use a third-party mail provider such as SendGrid, Mailgun, or Mailjet. All of these services offer APIs to send emails from applications.
App Engine Memcache support is not provided. Instead, use Memorystore for Redis.
App Engine Modules API is accessible using the
google/apiclient
library, but is no longer included in an official SDK. Use the environment variables and the App Engine Admin API to obtain information and modify your application's running services:Service Information How to access Current service name GAE_SERVICE
environment variableCurrent service version GAE_VERSION
environment variableCurrent instance ID GAE_INSTANCE
environment variableDefault hostname Admin API apps.get
methodList of services Admin API apps.services.list
methodList of versions for a service Admin API apps.services.versions.list
methodDefault version for a service, including any traffic splits Admin API apps.services.get
methodList of running instances for a version Admin API apps.services.versions.instances.list
methodApp Engine Search API support is not provided. You can host any full-text search database such as ElasticSearch on Compute Engine and access it from your service.
App Engine Task Queue API will be replaced by Cloud Tasks. You can enqueue tasks from your app using the Cloud Tasks REST API, RPC API, or the PHP Client library, and your push target can be an app in the PHP 7 runtime. Only push queues are supported.
Users API support is not provided.
Running your application locally
dev_appserver.py
is not supported by the PHP 7 runtime. To test your
application and run it locally, install a version of PHP that
is supported by the PHP 7 runtime
and set up a web server.
For example, start the HTTP server by running the following command:
php -S localhost:8080
Then, view your application in your web browser at http://localhost:8080.