How to Install Composer and PHP on Windows 10

How to Install Composer and PHP on Windows 10

Last updated on

In this guide we will install Composer and PHP on Windows 10 so that we can install dependencies for our web apps directly from Windows command line.

1. Download and Install Visual C++

In order to run PHP on Windows 10, you will need to install Visual C++ Redistributable for Visual Studio. You can download it from the Windows Download page or click the direct link below.

Once downloaded, run the installer and click Install.

Install Visual C++ Redistributable for Visual Studio 2015

2. Download and Extract PHP

Go to the Windows 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 (Jan 2020).

Once downloaded, create a new folder in c:\php7 (or wherever you prefer) and extract your PHP zip to it.

PHP7 for Windows extracted

3. Download and Install Composer

In the second step of Composer Setup, make sure the correct path to php.exe is set and click Next.

Installing Composer PHP Windows 10

If Setup prompts to create php.ini, allow it and click Next.

Skip the Proxy URL settings, just click Next then click Install.

Click Finish once install is complete.

4. Test PHP

If you have any Command Prompt windows currently open, close them now.

Open Command Prompt, type php -v and press Enter. You should now see the PHP version.

Windows 10 PHP 7 in Command Prompt

If it returns a PHP version, you can skip to Step 6 to test Composer.

If you get an error “‘php’ is not recognized as an internal or external command,
operable program or batch file.”, you may need to Add a Path Environment Variable.

5. Add Path Environment Variable

Composer setup usually does this for you, but if for whatever reason it didn’t, you can set one up 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 clicking the start menu and typing sysdm.cpl and press Enter.

Windows 10 view advanced system settings

In System Properties, click Environment Variables.

Windows 10 System Properties

In System Variables, click Path and then click Edit.

Click New, type the path to your PHP folder (c:\php7) and click OK.

Add new path environment variable Windows 10

Close the System Properties dialogue by clicking OK.

6. Test Composer

Open up Command Prompt and type composer -V.

If all was installed correctly, you should see a version number.

Composer in Windows 10 command prompt

Hurrah! You can now run Composer and PHP on Windows 10.

1 Star2 Stars3 Stars4 Stars5 Stars 4.79 (24 votes)

Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.

p.s. I increased my AdSense revenue by 68% using AI πŸ€–. Read my Ezoic review to find out how.

43 replies

avatar
  Subscribe  
newest oldest
Notify of
Ria
Guest
Ria
Ria
6 days ago

Thank you man,worked like magic

haris
Guest
haris
haris
19 days ago

bro when i typed php -v it showed me the version of php but when i try to check about composer nothing happend not an error nothing after typping command composer -v and press enter it just go on next line

Manjula C
Guest
Manjula C
Manjula C
1 month ago

IT was of Great help, Clear and easy, Thank you, it made my day

Kate
Guest
Kate
Kate
1 month ago

Thank you for your tutorial. Super clear and very helpful!

Felix Basher
Guest
Felix Basher
Felix Basher
2 months ago

Thank you!

rpcbl_com
Guest
rpcbl_com
rpcbl_com
3 months ago

sysdm.cpl file not running is there any problem with my system pc . or any thing else

Hassan Rashid
Guest
Hassan Rashid
Hassan Rashid
3 months ago

it works, Thanks for your clear tutorial

Cyrille Pierlot
Guest
Cyrille Pierlot
Cyrille Pierlot
3 months ago

Thanks a ton!
Pretty detailed tutorial. I don’t know anything PHP related … yet it worked for me πŸ™‚

Jose
Guest
Jose
Jose
3 months ago

Thank you for the guide, but I have a problem, when I execute: “php -v” this open result in other cmd window and close inmediately, and when I install composer, I get this message:

“Your PHP is very old (1.0.0) and must be upgraded to a recent version.”

php in command line works, but always open a new cmd window.

php version tested: 7.3 and 7.4
windows version: windows 10 (1909)

Can you help me?

John Stevenson
Guest
John Stevenson
John Stevenson
4 months ago

You can skip the 3. Add Path Environment Variable step altogether, because Composer-Setup will do this for you. You just need select the PHP version you want to use, as shown in 4. Download and Install Composer

Note that this will always offer the PHP version found in your Path.

Shrek
Guest
Shrek
Shrek
4 months ago

Thank you for this beauty

Kamatchi
Guest
Kamatchi
Kamatchi
4 months ago

The Composer installer script was not successful [exit code 1].
Script Output:
The “https://getcomposer.org/versions” file could not be downloaded: failed to open stream: An attempt was made to access a socket in a way forbidden by its access permissions.

This error will occured when I run composer setup file. Any solution for this???

Bram
Guest
Bram
Bram
4 months ago

Big Up ! Worked fine

ks
Guest
ks
ks
4 months ago

it works , thank you !

samiha
Guest
samiha
samiha
5 months ago

thinks, this helped

ducpa
Guest
ducpa
ducpa
5 months ago

Thanks you, it works!

Khizar Sami
Guest
Khizar Sami
Khizar Sami
6 months ago

Thank you It works

emmanuel
Guest
emmanuel
emmanuel
6 months ago

thanks very much your steps are pretty clear and easy to follow it was really helpful

Muhammad Nur Yusof
Guest
Muhammad Nur Yusof
Muhammad Nur Yusof
6 months ago

Thank youuu

here a love for u

<3 muah

top
Guest
top
top
6 months ago

Thank you for your good tutorial

musa salisu
Guest
musa salisu
musa salisu
6 months ago

please i need a help
C:\php7>composer require phpoffice/phpspreadsheet
Using version ^1.10 for phpoffice/phpspreadsheet
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
– phpoffice/phpspreadsheet 1.10.1 requires ext-gd * -> the requested PHP extension gd is missing from your system.
– phpoffice/phpspreadsheet 1.10.0 requires ext-gd * -> the requested PHP extension gd is missing from your system.
– Installation request for phpoffice/phpspreadsheet ^1.10 -> satisfiable by phpoffice/phpspreadsheet[1.10.0, 1.10.1].

To enable extensions, verify that they are enabled in your .ini files:
– C:\php7\php.ini
You can also run php --ini inside terminal to see which files are used by PHP in CLI mode.

Installation failed, deleting ./composer.json.

sira
Guest
sira
sira
7 months ago

Hey.Thanks so much

Duon
Guest
Duon
Duon
7 months ago

Thank you so much !

Hasan
Guest
Hasan
Hasan
7 months ago

Thanks

Sharon Chapman
Guest
Sharon Chapman
Sharon Chapman
7 months ago

This was very helpful, thank you for taking the time to explain this.

LuiKang
Guest
LuiKang
LuiKang
7 months ago

Thank you very much!

Abdelrahman Elshorafa
Guest
Abdelrahman Elshorafa
Abdelrahman Elshorafa
8 months ago

Alslam Alaykom

Thanks for your effort πŸ™‚

Flexx
Guest
Flexx
Flexx
9 months ago

Hello

Sorry for my third message but i’m happy now thanks
comment image

I have solved my problems what I had whit it

Thanks

Flexx
Guest
Flexx
Flexx
9 months ago

Hello

Thanks for this but I have a little problem on step 2

I can not install that file it says setup failed

I get this messagecomment image

Already thanks for helping me

Flexx
Guest
Flexx
Flexx
9 months ago

Hello

Step 2 I have newer version so that is okay

Now I have a new problem and that is this one
comment image

Already thanks for helping me

Oto Porchxidze
Guest
Oto Porchxidze
Oto Porchxidze
9 months ago

thank you bro. you make my life easier πŸ™‚

Eugene
Guest
Eugene
Eugene
9 months ago

Its work!

Renan
Guest
Renan
Renan
10 months ago

Thanks for this

emmalen
Guest
emmalen
emmalen
11 months ago

thank you for this. πŸ™‚

Andon
Guest
Andon
Andon
11 months ago

Thanks, all works πŸ™‚