PHP Composer (Composer) is a tool that enables the download and installation of various external sources and libraries for projects based on PHP thus it also known as “Dependency Management Tool”. It also now helpful because there are so many open-source projects no longer deliver ZIP archives or other installation packages – they reference the respective GitHub repositories. Thus, Composer makes it easy to start with PHP project for development or production.
PHP Composer installation on Windows 10
Here we will let you know how to install Composer for PHP, however, we start with PHP installation on Windows 10 first and if you already have it on your system then you can directly move to Step 6 of this tutorial.
Step 1: Download PHP on Windows 10 or 7 for Composer
So, here I am assuming that you don’t have PHP on your Windows 10 or 7, because to get the Composer on the system, it must has the PHP: Hypertext Preprocessor. Therefore, go to the official website and download the zipped file of PHP for Windows.
Step 2: Extract PHP zipped file in C: Drive
To install PHP on Windows, we don’t need any setup. Just go to C: Drive and create a folder php7 and extract the above downloaded zipped files of PHP into it. You can use the default Windows extractor, Winzip or any other tool.
Step 3: Add Environment Variables for PHP in Windows 10 or 7
So, now we have PHP files on our Windows but to use it globally throughout on the system, we have to add its path to the system variables. After that, we don’t need to use the whole path of the PHP folder to run the
php.exe file. Thus, press Windows + R keys on the keyboard simultaneously to open the RUN box. In that type
The above RUN command will open the System properties, where select the Advanced Tab and then Environment Variables.
From the opened window go to System Variable section and select the Path and then click the Edit button.
Select the New… button and type
C:/php7 then click the OK button and again the same to save and close it.
Step 4: Install VC5 (Visual C++ Redistributable for Visual Studio)
The PHP requires VC5 to run on Windows, thus we need at least Visual C++ Redistributable for Visual Studio 2015 to make it work on our system properly. Use this link to download VC5 on Windows.
An executable file will get downloaded and just like any other Windows software install it.
Step 5: Check the PHP installation via Command prompt
Finally, open your command prompt and type
php -v, it will give the information of the installed PHP on your Windows 10 or 7.
See the below screenshot for reference:
Step 6: Download and Install Composer on Windows 10 or 7
We already have PHP on our system, its time to set up the Composer Dependency management tool for it. For that simply go to the official website of it and download the Composer version for WIndows. It will be in executable form, so just run it like any other Windows software.
1. Download and run Composer-Setup.exe. Click the Next button.
2. The setup will automatically select the path of the PHP, however, if it does not then do it manually.
3. If the folder doesn’t have the php.ini, it will through an error and will attempt to create the one for it.
4. Skip the Proxy setting and simply click on the Next button.
5. Finally, select the install button and the setup will download install the composer on your Windows 10, 8, 7 computers.
Step 7: Test Composer is working or not
Open Command prompt, if already you have then close and run it again. To check the installed composer version simply type the command:
Example to install packages using Composer on Windows
Now we already have this Dependency Manager on our system, let’s use it to install some libraries or packages for some PHP project.
I just assume that you already have some project; let’s say you want to use WordPress for that. Or simply you want to use the Composer to get and start with WordPress, thus the command will be:
composer require johnpbloch/wordpress": "*"
Yes, web server and other things are required to use the WordPress CMS on Windows, and here I used this command to just give you an idea about its command.
- How to Create Windows 10 installation media
- How to install Virtualbox guest additions Windows or Linux
- 5 Best Linux Distro for Windows users as alternatives- 2020
- Install Composer on Ubuntu Linux