Migrating Your App from PHP 5.5 to PHP 7

Learn how to migrate your PHP 5.5 application to the PHP 7.2 or PHP 7.3 (beta) runtimes 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.2 and PHP 7.3 runtimes 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.2 and PHP 7.3 runtimes.
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 Cloud Identity and Access Management 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.2 and PHP 7.3 runtimes have 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.2 and PHP 7.3 runtimes do 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.
  • Cloud Datastore is accessible through the google/cloud-datastore client library. To get started see the Cloud Datastore Client Libraries page.
  • App Engine Images 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.
  • App Engine Mail API support is not provided. You will need to use a third-party mail provider such as SendGrid, Mailgun, or Mailjet to send email. All of these services offer APIs to send email from applications. To integrate Mailjet and SendGrid on your App Engine application, see the Sending Emails with Mailjet and Sending Emails with SendGrid documentation.
  • App Engine Memcache support is not provided, but similar functionality can be achieved using Redis Labs Cloud.
  • 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 apps.services.list method
    List of versions for a service Admin API apps.services.versions.list method
    Default version for a service, including any traffic splits Admin API apps.services.get method
    List of running instances for a version Admin API apps.services.versions.instances.list 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 PHP 7 using the Cloud Tasks REST API, RPC API, or the PHP Client library, and you can use a PHP 7.2 or PHP 7.3 App Engine standard service as a Push target. Only push queues are supported.

  • Users API support is not provided.

Running your application locally

dev_appserver.py is not supported with the PHP 7.2 and PHP 7.3 runtimes. To test your application and run it locally, you must download and install PHP 7.2 or PHP 7.3 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.

Оцените, насколько информация на этой странице была вам полезна:

Оставить отзыв о...

Текущей странице
App Engine standard environment for PHP 7.2 docs