Symfony is an object-oriented PHP framework that is based on the Model-View-Controller (MVC) pattern. This topic describes how to use Symfony to create an application and deploy the application in Web App Service.

Prerequisites

Configure a PHP development environment
Notice Before using the Laravel framework to develop applications, you must install PHP 5.5.9 or later.

Step 1: Install Symfony

  1. Use the following command to install the Symfony CLI tool.
    curl -sS https://get.symfony.com/cli/installer | bash
  2. Use the following command to move the executable file of the Symfony CLI tool to a Linux system directory that contains binary files for common commands.
    mv ~/.symfony/bin/symfony /usr/local/bin/symfony

Step 2: Create an application

  1. Use the following command to call the Symfony CLI tool and create a Symfony demo project.
    symfony new --demo webplusdemo

    The process requires a few minutes to complete. After the process is complete, a project named webplusdemo is created.

  2. Navigate to the project directory and use the following command to install the required dependencies.
    composer install
  3. Use the following command to start the Web server that is included in the Symfony CLI tool.
    symfony server:start
  4. Enter http://localhost:8000 in the address bar of a browser and view the homepage of a sample Symfony application.

Step 3: Create a deployment package

  1. Web App Service allows you to use NGINX or Apache to serve as a Web server. If you want to use Apache, you can navigate to a project directory and use the following command to create a file named .htaccess. If you want to use NGINX, you can skip this step.
    composer require symfony/apache-pack
  2. Use the following command to archive the directory and create a deployment package named webplusdemo.zip.
    zip -r webplusdemo.zip . /

Step 4: Deploy the application in Web App Service

  1. Log on to the Web+ console.
  2. On the Overview page, click Create in the upper-right corner of the Last Updated Deployment Environments section.
  3. In the Basic Information step, select PHP in the Technology Stack Type setting, and enter an application name and application description. After the configuration is complete, click Next.
  4. In the Deployment Environment Information step, enter a deployment environment name, and select Upload Local Application in the Deployment Environment Source setting. Upload the newly compressed deployment package named webplusdemo.zip, configure the deployment package version, and click Creation Complete.
  5. In the Creation Complete step, click View Application or Creation Complete to go to the Overview tab of the Application Details page. Click the name of a deployment environment to go to the Overview tab of the Deployment Environment Details page. Then, click the link next to the Public IP Address label and view the homepage of the application.

More information