How to Install Composer and PHP on Windows 10/11

A graphic on a light purple background showing a stylized green elephant looking through a white window frame, with the text Composer & PHP on Windows.

We may earn a referral fee at no additional cost to you when you shop through the links on this page.

You opened cmd.exe, typed composer require, and Windows answered 'composer' is not recognized as an internal or external command. This DevAnswers walkthrough installs PHP 8.5 (or 8.4 if you need to match an existing server) plus Composer on Windows 10, 11, or Windows Server 2019/2022, covering the Visual C++ Redistributable prerequisite, the NTS vs TS download choice, and both Composer install paths.

Prerequisites 

  • 64-bit Windows 10 (build 19045+), Windows 11, or Windows Server 2019/2022.
  • Administrator rights, required to extract PHP into C:\php and modify the system PATH.
  • About 250 MB of free disk for PHP plus Composer.
  • The Microsoft Visual C++ Redistributable. The Microsoft documentation states that “PHP requires the Visual C runtime (CRT)” and that the “Microsoft Visual C++ Redistributable for Visual Studio 2022 is suitable for use with all PHP versions“. This is the most-commonly-missed prerequisite. Install the VS 2022 redistributable from Microsoft’s redistributable downloads page before extracting PHP.

Choose Your PHP Version: 8.5 or 8.4 

Two PHP branches are in active support today, and either works fine with current Composer. Pick based on what your deployment target runs.

  • PHP 8.5 (default recommendation). Per php.net, “the current latest stable release of PHP is PHP 8.5.6, which was released on May 7, 2026“. PHP 8.5 reached General Availability on November 20, 2025, and active support runs until December 31, 2027.
  • PHP 8.4. Pick this only if your production server is still on 8.4 and you want your local environment to match. PHP 8.4’s active support began on November 21, 2024 and is scheduled to end on December 31, 2026.

Composer itself has a much lower floor: per the official Composer documentation, “Composer in its latest version requires PHP 7.2.5 to run“, so both 8.4 and 8.5 are well above what Composer needs. If you need to run multiple PHP versions on the same machine for different projects, our guide on running multiple PHP versions with Apache covers the parallel-install pattern.

Non-Thread Safe (NTS) vs Thread Safe (TS): Which to Download 

The windows.php.net download page lists every release in two flavours: Non-Thread Safe (NTS) and Thread Safe (TS). The choice depends entirely on what runs your PHP. The download page itself spells out the rule for each common case:

  • CLI and Composer: “Use NTS (Non-Thread Safe)“. Anything you run from cmd.exe or PowerShell, including composer itself, falls into this bucket.
  • IIS with FastCGI: “Use NTS (Non-Thread Safe)“. The FastCGI handler runs PHP as a separate process, so thread safety isn’t required.
  • Apache with mod_php: “Use TS (Thread Safe)“.

If you’re setting up PHP for local development, Composer use, or to run a CLI script, pick NTS. The most common reason to pick TS is if you specifically need Apache plus mod_php on Windows, which is rare in 2026; even Apache deployments now usually pair with PHP-FPM via mod_proxy_fcgi (which uses NTS).

What Does VS17 Mean on the Download Page 

Every PHP for Windows download is tagged with a compiler version like VS17. From the windows.php.net documentation: “The VS17 build of PHP for Windows refers to versions of PHP compiled using the Microsoft Visual Studio 2022 C++ compiler“. The number (17) is the internal version of the Visual Studio IDE; VS 2022 is the seventeenth release.

This naming “is used to distinguish builds based on the compiler toolset and corresponding C++ Redistributable requirements“. In practice, a VS17 binary needs the VS 2022 redistributable installed (the prereq we covered above), which Microsoft documents as suitable for all PHP versions. Older PHP releases shipped as VS16 (Visual Studio 2019), and the VS 2022 redistributable covers their runtime as well.

Install PHP 8.5 on Windows 

With the VC++ Redistributable installed, you’re ready to download and extract PHP. We’ll put it at C:\php: short, no spaces, easy to type, easy to add to PATH.

  1. Open windows.php.net/download and download the VS17 x64 Non Thread Safe zip for PHP 8.5 (or 8.4, depending on what you chose above). If you picked TS in the NTS vs TS section earlier because you’ll run Apache with mod_php, download the VS17 x64 Thread Safe zip instead.
  2. Create the folder C:\php and extract the zip’s contents directly into it (you should see php.exe, php-cgi.exe, and an ext folder at the top level).
  3. In the C:\php folder, copy php.ini-development to php.ini as your starting configuration. Use php.ini-production instead if this install is for a production server. Then open php.ini in a text editor, find the line ; extension_dir = "ext" in the Windows section, and uncomment it (remove the leading ;) so PHP looks in C:\php\ext\ for extension DLLs.
  4. Add C:\php to the system PATH so Windows can find php.exe from any directory.

Open an elevated PowerShell prompt. Right-click the Start menu and choose Terminal (Admin) on Windows 11, or Windows PowerShell (Admin) on Windows 10 / Server 2019. Then run:

PowerShell
$machinePath = [Environment]::GetEnvironmentVariable('Path', 'Machine')
[Environment]::SetEnvironmentVariable('Path', $machinePath + ';C:\php', 'Machine')

This reads the current Machine-scope PATH explicitly (using $env:Path instead would read the combined User+Machine value and bake your User entries into the system PATH), appends C:\php, and writes the result back. Per Microsoft’s documentation, “The PATH environment variable is a list of directories Windows searches when you run an executable from the command line“. Close the PowerShell window and open a fresh one for the change to take effect.

Verify PHP is on the path:

PowerShell
php --version

You should see something like PHP 8.5.6 (cli) (built: ...) (NTS Visual C++ 2022 x64), or (TS Visual C++ 2022 x64) if you picked the Thread Safe build. If you instead see “PHP is not recognized“, the new PowerShell session didn’t pick up the updated PATH. Close every cmd.exe and PowerShell window, then try a fresh one. If you see a Visual C++ runtime error, the VC++ 2022 Redistributable from the prerequisites step is not installed.

The Composer documentation describes the Windows installer as the easiest path: “Installation – Windows. Using the Installer. This is the easiest way to get Composer set up on your machine“. For most readers (single-user Windows desktops, local development setups) this is the right choice.

  1. From the Composer documentation: “Download and run Composer-Setup.exe” (you can grab it directly from getcomposer.org/Composer-Setup.exe).
  2. The installer asks where php.exe lives. If you followed the previous section, point it at C:\php\php.exe. The installer will check a few php.ini settings and warn you if anything is missing.
  3. Optional: enter a proxy URL if your network requires one for outbound HTTPS to packagist.org.
  4. Per the Composer docs, the installer “will install the latest Composer version and set up your PATH so that you can call composer from any directory in your command line“. You don’t have to edit PATH yourself.

After the installer finishes, open a fresh cmd.exe or PowerShell window and run:

PowerShell
composer --version

You should see a line like Composer version 2.x.x .... From this point you can run composer require, composer install, or composer create-project from any directory.

Install Composer Manually with composer.phar (PowerShell Path) 

If you can’t run a GUI installer (locked-down corporate machine, CI build agent, remote SSH session, or you’re provisioning Composer for multiple users) install Composer manually as a PHAR file. The Composer documentation describes this path as: “Change to a directory on your PATH and run the installer following the Download page instructions to download composer.phar. Create a new composer.bat file alongside composer.phar“.

For these instructions, install Composer into C:\php alongside PHP, since C:\php is already on your PATH from the install-PHP step. The shape below uses PowerShell’s Invoke-WebRequest for the download (instead of php -r "copy(...)" from the official docs) so the install works before any PHP extensions are enabled. Always grab the current SHA-384 hash from the getcomposer.org download page and substitute it into the verify step.

PowerShell
cd C:\php
Invoke-WebRequest -Uri 'https://getcomposer.org/installer' -OutFile composer-setup.php -UseBasicParsing
php -r "if (hash_file('sha384', 'composer-setup.php') === 'EXPECTED_HASH_FROM_DOWNLOAD_PAGE') { echo 'Installer verified'.PHP_EOL; } else { echo 'Installer corrupt'.PHP_EOL; unlink('composer-setup.php'); }"
php composer-setup.php
Remove-Item composer-setup.php

Important: replace EXPECTED_HASH_FROM_DOWNLOAD_PAGE with the SHA-384 string that appears on the getcomposer.org download page at the time you run the install. Composer rotates this hash with each release; pasting an old one from a tutorial will silently install nothing.

Per the docs, “The installer will check a few PHP settings and then download composer.phar to your working directory“. Once you have composer.phar in C:\php, create a Windows shim so composer works as a command. From an elevated PowerShell prompt:

PowerShell
Set-Content -Path 'C:\php\composer.bat' -Value '@php "%~dp0composer.phar" %*' -Encoding ASCII

Now composer --version works from any cmd.exe or PowerShell session, exactly as if you had used Composer-Setup.exe. To upgrade later, run composer self-update.

Next steps 

Confirm both binaries are on your PATH from a fresh terminal:

PowerShell
php --version
composer --version

Most projects need a few extensions enabled before composer install succeeds: curl, mbstring, openssl, zip, and fileinfo are the common ones. They’re all bundled in the Windows zip; you just have to uncomment them in your C:\php\php.ini from step 3 of the install. See our companion guide on finding and editing php.ini for the extension= syntax. From there, common next steps are connecting PHP to a database with PHP MySQLi prepared statements, or, if you’ll deploy to a Linux production server, follow our guide on upgrading PHP on Ubuntu and Debian so your local 8.5 environment matches the host. The managed alternative is a platform such as Cloudways, where the PHP version is a dropdown in the server settings rather than a package install. One thing to check first: as of September 2026 its newest offered version is PHP 8.4, so a local 8.5 environment would need to target 8.4 there.

Support DevAnswers
Written, tested and maintained by one developer. Your support keeps these guides accurate and ad-light.
Buy me a coffee

83 replies

Leave a reply

  1. Tobias

    Danke für die super Beschreibung!!

  2. Jean-Noel

    Merci pour ce guide clair et rigoureux.
    Jean-Noel

  3. Mike Quiroz

    todo me funcionó perfecto, Gracias hermano.

  4. Qaisar Abbas

    Thanks alot

  5. Bethel

    Thanks, it’s a straight forward description.

  6. Klim

    Oh Thankyou!

  7. Isreal Jahdey

    A great solution provider, so helpfull.

  8. Arulseeli

    Great….. It is an user-friendly guidance for the beginners. Thanks a lot…..

  9. Orb

    Thank you very much for such informative article

  10. Sagar

    Thank you very much for this blog. It is very user friendly and very important for the beginners.

  11. Nudsanon

    Thank yopu so much tram for your procedure

  12. Keith Rowley

    Very, very helpful indeed. Thank you;

  13. JC

    You are great, thank you

  14. sean

    Thank you so much!

  15. venkatesan

    nice

  16. Joel

    Thanks for best help and explanation. God bless u

  17. apunda

    Where then does things like laravel come in haven’t heard you mentioning any of them

    the tutorial was fine

  18. Mohan

    very clear steps. Thanks

  19. amrinaas

    Thank you so much! The tutorial very clear!!:)

  20. yasmine176

    thank you so much for your help , it helped me a lot !!!!

  21. Sourav

    Thank you so much, guys

  22. George

    Thank you very much.
    This is very helpful for me.

  23. LightFury

    Thank you.
    The explanation was clear and it was executed at once.

  24. Jowee

    Thank you SO much

  25. Kevin

    Nice nice. Many thanks

  26. ronga

    Very helpful for a newbie, thank you.

  27. Benjamin Kipkorir

    Thank you

  28. Thiago Petherson

    Muito Obrigado

  29. Angel

    When I want to create a project, it gives me:
    $ composer install
    Composer could not find the config file: C:composer;C:UsersAngelAppDataRoamingComposervendorbin;c:UsersSYSTEMAppDataRoamingComposervendorbin;
    To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ “Getting Started” section

    What could it be?

  30. Kira

    Really glad I found this…would have been able to stumble through on my own but am happy I didn’t have to. 🙂 Thank you!

  31. cindy

    thanks.

  32. laynkulan

    thank you.

  33. Ola

    Thank you it helps

  34. Jay

    Thank you.. it was really helpful

  35. MarioSP

    Thanks, it was helpful for such a newbie like me 🙂

  36. Grace Esohe

    Thank you so much
    I am a newbie to composer i am grateful for your input and tutorial. it was really helpful
    God Bless you.

  37. Vasu Narang

    while installing composer , an error is coming

    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.

    plz help me out from this situation…

    1. DevAnswers

      Sounds like a Windows issue with permissions or firewall or something.

      Did you run the install as Administrator?

    2. SamM

      I dug for this answer for many hours without success.
      Finally I disabled my Bitdefender firewall, and was able to install Composer.

  38. Bor

    i don’t know how i should be thanking you right now, this is amazing, im gonna turn off the adblock and run the page again just to give something back

  39. Ria

    Thank you man,worked like magic

  40. haris

    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

    1. Chan

      Make sure you do the cmd “run in administrator”. I was the same as you, so I ran in administrator and it worked.

  41. Manjula C

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

  42. Kate

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

  43. Felix Basher

    Thank you!

  44. rpcbl_com

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

  45. Hassan Rashid

    it works, Thanks for your clear tutorial

  46. Cyrille Pierlot

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

  47. Jose

    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?

    1. DevAnswers

      Have you tried opening CMD in administrator mode before running the commands? Is this the first time you’ve installed PHP on Windows 10?

      1. jose

        Yes, in administrator mode I get the same result, I have used php 7.2 in window 7 without any problem, but it is the first time that I use php in windows 10.

          1. Joe

            With your help I could see that when I install php in: “D:\php7” get the error, but works fine in: “C:\php7”, searching I found that my folder: “D:\php7” did not had write permissions, I solved my problem by changing the permissions to: read and write. Thank you very much.

  48. John Stevenson

    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.

    1. DevAnswers

      Thanks, I’ve updated the article.

  49. Shrek

    Thank you for this beauty

  50. Kamatchi

    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???

    1. DevAnswers

      Are you behind a firewall or running a virus scanner? You might need to give the installer access.

  51. Bram

    Big Up ! Worked fine

  52. ks

    it works , thank you !

  53. samiha

    thinks, this helped

  54. ducpa

    Thanks you, it works!

  55. Khizar Sami

    Thank you It works

  56. emmanuel

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

  57. Muhammad Nur Yusof

    Thank youuu

    here a love for u

    <3 muah

  58. top

    Thank you for your good tutorial

  59. musa salisu

    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.

    1. DevAnswers

      Yes, open C:\php7\php.in in text editor and remove the semicolon before the extensions your require.

      ;extension=gd2

  60. sira

    Hey.Thanks so much

  61. Duon

    Thank you so much !

  62. Hasan

    Thanks

  63. Sharon Chapman

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

  64. LuiKang

    Thank you very much!

  65. Abdelrahman Elshorafa

    Alslam Alaykom

    Thanks for your effort 🙂

  66. Oto Porchxidze

    thank you bro. you make my life easier 🙂

  67. Eugene

    Its work!

  68. Renan

    Thanks for this

  69. emmalen

    thank you for this. 🙂

  70. Andon

    Thanks, all works 🙂