In this guide, we will show you how to install Composer and PHP on Windows 10 so that you can install dependencies for your web apps directly from the Windows command line.
Step 1 :- Install Visual C++
To run PHP on Windows 10, you have to install Visual C++ Redistributable for Visual Studio. You can download it from the Microsoft Windows Download page or click the below direct link.
After finished download run the installer and click Install.
Step 2 :- Download and Extract Latest Version PHP
Go to the PHP download page and download the .zip of the version of PHP you require.
In this guide, we are installing PHP 7.4 VC15 x64 Non Thread Safe, which is the latest version as of writing (June 2020).
After finishing the download create a new folder in c:\php7 (or wherever you prefer) and extract your PHP zip to it.
Step 3 :- Download and Install Composer
To download the Composer Setup, visit the Composer Download page or click the below direct link.
Once download complete, click on the setup file and you will see the popup of composer setup, make sure the correct path to php.exe is set and click Next.
Step 4 :- Test PHP
Open CMD and type php-v and press Enter. You should now see the PHP version. If you see the PHP version than Skip Step 5 and go to Step 6.
If you see the error like “‘php’ is not recognized as an internal or external command, operable program or batch file.” You should add the PHP path into the environment variables.
Step 5 :- Add Path Environment Variable
Composer setup usually sets the PHP path into environment variables for you, but if for whatever reason it didn’t, you can add the php path into the environment variables manually.
So that you don’t have to type the whole path to php.exe every time you run a PHP command, you should add c:\php7 as a path environment variable. Open System Properties by visiting the following path. Control Panel\System and Security\System
Click on the Advanced system settings option.
After click on advanced system setting, you will see the below window than click on environment variable option.
In System Variables, click on the Path and then click Edit.
Click on New, type the path to your PHP folder (c:\php7) and click OK.
Close the System Properties by clicking OK.
Step 6 :- Test Composer
Open the Command Prompt and type the composer -V command.
If all was installed correctly than you should see a version number.