Package your PHP application as a ZIP file that meets Serverless App Engine (SAE) requirements, and then deploy the package to SAE as an application.
Prerequisites
PHP code package — Package your application as a ZIP file that conforms to the PHP code package specifications.
PHP environment — Identify the PHP environment that is compatible with your code.
Network resources — (Optional) To deploy the application to an existing namespace, create the namespace, vSwitch, and security group in advance.
Application editions
The Lightweight Edition and Professional Edition are currently in an invite-only beta phase. For users not participating in the beta test, applications are created as the Standard Edition by default.
The following table describes the features that each edition includes.
| Edition | Included features |
| Lightweight Edition | Provides the minimum feature set required to run an application. Does not support the Application Monitoring and Microservices Governance features. |
| Standard Edition | Includes the Basic Application Monitoring feature. The Advanced Application Monitoring and Microservices Governance features must be enabled and purchased separately. |
| Professional Edition | Includes the Advanced Application Monitoring and Microservices Governance features, which do not need to be enabled or purchased separately. |
Microservices Governance provides its features for Java applications. Because the editions differ only in the features listed in the preceding table, application monitoring is the capability to weigh when you choose an edition for a PHP application. For the monitoring data and the governance features that each edition provides, see the "Advanced settings" section of this topic.
Create the application
On the SAE Application List page, select the target region and namespace in the top navigation bar, and then click Create Application.
Select an application edition. For a comparison of the editions, see the "Application editions" section of this topic.
On the Create Application page, enter a custom Application Name.
Select the namespace type for the application. A namespace is equivalent to a Kubernetes namespace and can be used to isolate resources in different environments.
ImportantYou cannot change the namespace of an application after it is created. Confirm which namespace the application belongs to before you create it.
System Created — Use the default namespace, vSwitch, and security group created by the system in the current region. Select this option when the application does not need to reuse existing network resources.
Existing Namespace — Select the namespace, vSwitch, and security group that you created in advance. Select this option when the application must run in network resources that you prepared.
Set Application Deployment Method to Code Package-based Deployment, and then click Configure Code Package-based Deployment on the right.
For Technology Stack Programming Language, select PHP, and then select the PHP environment that is compatible with your code.
Configure the code package parameters, and then click OK. The parameters are described in the "PHP ZIP package parameters" section of this topic.
In the Capacity Settings section, set Resource Type, Single Instance Type, and Instances.
(Optional) Click Next: Advanced Settings to configure desired features. The available features are described in the "Advanced settings" section of this topic.
Click Create Application with One Click or Create Application.
PHP ZIP package parameters
The following table describes the parameters that you configure for a PHP ZIP package.
| Parameter | Description |
| Upload Method | Upload a local code package or enter the URL of the code package. |
| Version | Enter an application version number or select Use Timestamp as Version Number. |
| Time Zone Settings | Select the time zone in which the application runs. |
| Startup Command | If you packaged your code according to the PHP code package specifications, you do not need to configure a startup command. |
| Custom Runtime Environment Settings | (Optional) If enabled, you can pre-install tools, download or modify files, and install runtime dependencies or extensions for your application as needed. |
| Custom php.ini [TODO: confirm UI term] | (Optional) When enabled, enter the content of the php.ini configuration file. SAE starts the application by using this configuration. |
Customize the runtime environment
If you turn on Custom Runtime Environment Settings, you can configure the following items:
PHP Extension.
PHP PECL Extension.
Customize the runtime environment by using the command line. The following script is an example:
#!/bin/bash docker-php-ext-configure gd \ --with-gd \ --with-webp-dir \ --with-jpeg-dir \ --with-png-dir \ --with-zlib-dir \ --with-xpm-dir \ --with-freetype-dir \ && docker-php-ext-install -j$(nproc) gd
Customize the php.ini configuration
In php.ini Mount Path, set the mount path of the configuration file, for example, /usr/local/etc/php/php.ini.
After the application is deployed, run the following command in Webshell to verify that the configuration file is mounted:
php -i | grep ini
# Example output: Loaded Configuration File => /usr/local/etc/php/php.iniAdvanced settings
In Advanced Settings, you can configure the following optional features for the application.
The following features rely on services that incur additional charges: the MSE service registration and discovery center, NLB, CLB, gateway routes, NAT Gateway, elastic IP addresses (EIPs), NAS, OSS, databases, Simple Log Service, and Kafka.
Runtime environment and lifecycle
Runtime configuration — You can change variables or configuration files in the runtime environment after deployment without rebuilding the image by setting environment variables, setting hosts bindings, injecting configuration information, and injecting confidential information.
Health checks — You can set a health check to monitor whether application instances are running normally and ready to handle traffic. Unhealthy instances are automatically restarted, and traffic is not routed to an instance until it is ready.
Lifecycle management — You can use application lifecycle management to customize the commands that run after an application starts and before it stops, and to implement graceful shutdown.
Network access and service invocation
Service invocation — Use service registration and discovery to enable service invocation between applications.
External access — Enable external access to an application by binding an NLB, binding a CLB, or configuring a gateway route.
Outbound access — Allow an application to access external resources or services by configuring a NAT Gateway or binding an EIP to an application instance.
Data persistence
Store application data in NAS, OSS, or a database to prevent data loss when an application is changed or stopped.
Logging and monitoring
Logs and metrics — After you deploy an application, you can view real-time logs and view resource usage and load without additional configuration. You can also output logs to Simple Log Service or Kafka for centralized management and analysis.
Application monitoring — ARMS helps you track application health, quickly find failed and slow APIs, identify performance bottlenecks, and reproduce call parameters, which improves production troubleshooting efficiency.
For Standard Edition applications, you can view ARMS Basic Edition monitoring data after deployment without additional configuration. You can also enable and purchase ARMS Premium Edition monitoring.
For Professional Edition applications, after you enable Application Monitoring in Advanced Settings and deploy the application, you can view ARMS Premium Edition monitoring data. No additional fees are required.
Other features
Microservices Governance — Microservices Governance provides Graceful Start and Shutdown, traffic protection, end-to-end canary release, and Intra-zone Provider First for Java applications. Consider this scope before you enable the feature for a PHP application.
For Standard Edition applications, go to the application details page after deployment to enable and purchase the MSE Microservices Governance feature.
For Professional Edition applications, after you enable Microservices Governance in Advanced Settings, you can configure Graceful Start and Shutdown. For more features, go to the application details page after deployment. No additional fees are required.
CPU Burst — You can enable the CPU Burst feature to avoid wasting resources when CPU requirements are higher at startup than during normal operation.
Sidecar containers — You can decouple and standardize non-business features from the main container by adding a sidecar container.
Verify the deployment
Creating the application takes about 1 to 2 minutes. Verify the result as follows:
The application appears on the Application List page.
You can view change records to verify that the deployment was successful.
Handle a failed deployment
If the deployment fails, no application instance is created. Troubleshoot the issue based on the error message in Change Details.
Next steps
Change the application configuration — On the Application List page, click the target application to go to its details page. Then, click Deploy Application or Modify Application Configurations at the top. The application automatically restarts to apply the new configuration, so perform this operation during off-peak hours.
Log on to an instance — You can log on to an application instance by using Webshell and interact with the instance by using console commands.
Scale the application and reduce costs — You can manually adjust the number of instances and the instance specification, or automatically adjust the number of instances by configuring an auto scaling policy. You can also reduce costs by enabling idle mode.