Before testing PHP applications in a local environment, you must prepare the environment. This topic describes how to configure a PHP environment. It also provides download links for related tools.

Install PHP

Proceed as follows to install PHP and several commonly used extensions. If you do not have specific requirements, we recommend that you download the latest installation package.

Linux
  1. Download an installation package for Linux from the PHP official site. For example, php-7.3.8.tar.bz2 (sig).
  2. Open the directory where the installation package resides.
  3. Use the following command to install the package.
    $ sudo yum install php
macOS
  1. Download an installation package for macOS from the PHP official site. For example, php-7.3.8.tar.bz2 (sig).
  2. Use the following command to install the package.
    $ brew install php
Windows
  1. Download an installation package for Windows from the PHP official website. For example, PHP 7.3 (7.3.8).
  2. Open the directory where the installation package resides and double-click the package to install PHP. No further configuration is required.

Install Composer

Composer is an application-level package manager that helps you manage dependencies. You can use Composer to install libraries, track dependencies for applications, and create projects for popular frameworks.

  1. Use the following command to retrieve a PHP script from getcomposer.org to install Composer.
    # curl -sS https://getcomposer.org/installer | php
  2. The installer creates a PHAR file in the current directory. Move the file to a directory that is added to the PATH environment variable. Then, you can run the file under all folders.
    $ mv composer.phar ~/.local/bin/composer
  3. Use the require command to install Twig.
    $ composer require twig/twig

Composer adds libraries that are installed on your localhost to the composer.json file of your project. When you deploy an application, Web App Service uses Composer to install libraries that are listed in the file on an application instance of your deployment environment. If you have any questions when you install Compose, visit the Composer official website.

Install an IDE

An integrated environment (IDE) is a software application that provides developers with comprehensive tools for software development. Typically, these tools include a code editor, compiler, debugger, and graphical user interface (GUI). These tools help developers significantly improve development efficiency. The following lists IDEs that are commonly used for PHP development: