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.
PrerequisitesConfigure a PHP IDE
Step 1: Install Symfony
- Use the following command to install the Symfony CLI tool.
curl -sS https://get.symfony.com/cli/installer | bash
- 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
- 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.
- Navigate to the project directory and use the following command to install the required
- Use the following command to start the Web server that is included in the Symfony
- 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
- 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
- Use the following command to archive the directory and create a deployment package
zip -r webplusdemo.zip . /
Step 4: Deploy the application in Web App Service
- Log on to the Web+ console.
- On the Overview page, click Create in the upper-right corner of the Last Updated Deployment Environments section.
- 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.
- 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.
- 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.
- For more information about how to deploy an application in the console, see Deploy applications.
- For more information about how to use the CLI tool to create and deploy an application, see Use the CLI to quickly deploy applications.
- For more information about management tasks after you host an application, see Overview of application details.
- For more information about how to manage deployment environments where applications reside, see Deployment environment overview.