PHP 7.4 is now generally available.

Migrating Your App from PHP 5.5 to PHP 7

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 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:

ElementChange typeDescription
entrypointAdded Optionally, use this field to specify the command that will run when your app starts.
threadsafeDeprecatedAll applications are presumed to be threadsafe, meaning an instance can handle multiple requests at the same time.
api_versionDeprecatedPreviously required but not needed in the PHP 7 runtime.
librariesDeprecatedArbitrary third party dependencies can be installed using a composer.json metadata file.
  • The script field is optional and the only accepted value is auto. Use a web framework (like Laravel, Symfony, Slim, or a similar option) with in-app routing to execute a script when a request hits a specific route
  • The login field is not supported. Use Identity and Access Management (IAM) for user management.

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.

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 variable
    Current service version GAE_VERSION environment variable
    Current instance ID GAE_INSTANCE environment variable
    Default hostname Admin API apps.get method
    List of services Admin API method
    List of versions for a service Admin API method
    Default version for a service, including any traffic splits Admin API method
    List of running instances for a version Admin API method
  • App 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 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.