This topic describes how to install PHP and Composer on Windows.
Install PHP
Visit the official download page of PHP for Windows. Find x64 Thread Safe and download the ZIP file.
Decompress the ZIP file and configure environment variables.
Right-click the This PC icon and select Properties.
Click Advanced system settings.
On the Advanced tab of the System Properties window, click Environment Variables.
In the System variables section, find and select the Path variable and click Edit.
Click New to add the installation directory and extension directory of PHP. Examples:
D:\php
andD:\php\ext
.
Configure the php.ini file. The php.ini file is the PHP configuration file, which is mainly used to control the behavior and functions of the PHP interpreter.
Find the php.ini-development file in the decompressed folder. The file is typically used in a development environment. Rename the file to php.ini.
Check whether PHP is installed. Press the
Win+R
keys to open the Run window. Entercmd
and click OK to open Command Prompt. Enterphp -v
and press the Enter key. If the output is similar to the following code, PHP is installed.PHP 8.3.8 (cli) (built: Jun 4 2024 18:52:30) (ZTS Visual C++ 2019 x64) Copyright (c) The PHP Group Zend Engine v4.3.8, Copyright (c) Zend Technologies
Install Composer
Composer is a dependency management tool widely used by the PHP community. Composer provides features including dependency management, version control, automatic loading, and project initialization.
Download the Composer installer: Visit the official download page of Composer and click Composer-Setup.exe in the Windows Installer section.
Install Composer: Double-click the Composer-Setup.exe file and install Composer by following the installation wizard.
Check whether Composer is installed: Press the
Win+R
keys to open the Run window. Entercmd
and click OK to open Command Prompt. Entercomposer -V
and press the Enter key. If the output is similar to the following code, Composer is installed.Composer version 2.7.7 2024-06-10 22:11:12 PHP version 7.4.33 (D:\ide\PHP\php.exe) Run the "diagnose" command to get more detailed diagnostics output.