PHP7 is a general purpose scripting language well suited for web development. Composer is the defacto package manager for PHP7. This tutorial will show you how to install PHP7 and Composer on Windows 10 for use in a command prompt.
A common misconception is that you need a web server like IIS, Apache, or Nginx to get started with PHP7 development. In fact, PHP7 has its own built in web server that you can invoke at the command prompt. Modern PHP frameworks such as Opulence, Symfony, Cake, Laravel, WordPress, and many more support this.
Installing PHP7
Download the latest PHP7 (non-thread safe version) zip file from http://windows.php.net/
Extract the contents of the zip file into C:\PHP7
Copy C:\PHP7\php.ini-development to C:\PHP7\php.ini
Open the newly copied C:\PHP7\php.ini in a text editor.
Scroll down to “Directory in which the loadable extensions (modules) reside.” and uncomment: extension_dir = “ext”

Scroll down to the extensions section and uncomment the extensions you want to use.

Tweak other settings as needed.
Note: Don’t forget to keep your php.ini file in a safe place when you upgrade in the future!
Add C:\PHP7 to the Windows 10 system path environment variable.

In a command prompt test that the installation is successful by typing php -v

Installing Composer
On my computer I’ve created a C:\Users\dac\bin directory where I keep miscellaneous executables. This directory is in my user path.
Use a search engine to find a tutorial and do something similar. Optionally install composer in the C:\PHP7 directory you just created as it’s already in your path.
To get composer.phar, drop to a command prompt, cd into your target directory, and run:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php composer-setup.php php -r "unlink('composer-setup.php');"
(Important! Click here for a more secure and up-to-date install snippet.)
Next, create a new composer.bat file alongside the composer.phar file so that Windows 10 can execute it more easily. (Source)
echo @php "%~dp0composer.phar" %*>composer.bat
Test that it’s working by typing composer -V

Really good tutorial. Simple but effective! Thank you for this.
This is extremely helpful! I’ve never used Composer and was confused about where to start and how to get set up. I was done in a few minutes with your tutorial. Thank you so much for taking the time to write it!
Today is 2017-08-06. This manual is still correct and was very helpful.
Thanks.
Yeah thanks, the php worked greatly, but i need to connect it with apache and mysql database client. thanks
“Connecting to MySQL:” Just set your configs to point to a MySQL server. It can be downloaded, a VM, a Docker image, there many options. I personally run Vagrant, but I still need PHP on my Windows machine to do stuff. MySQL doesn’t have to be on the same server as PHP.
“Connecting to Apache:” I don’t understand this statement. PHP has it’s own built-in web server. Other options include IIS, Nginx, Caddy… Do you need .htaccess or something?
Everyone has their own preferences, but I personally prefer XAMPP for an Apache/mySQL install of PHP on Windows. For development, not Production.
almost smooth sailing for me, except I had to go back and enable the openssl extension in the php.ini and then after I created that composer.bat it was just echoing the line back to me until I closed and reopened that terminal. I’m using cmder which is a nice wrapper on top of conemu, dunno if thats why. It actually says restart your terminal in the “source” you noted for creating the .bat
In cmd it still says php is version 5.6.25. Do I have to delete the previous version?
The order of your path environment variables are important. Put PHP7 first, before PHP5, and it should work.
Thank you so much, your tutorial was helpful…
Works awesome… first good tut.
Thaks very much 🙂
Thank you! It really helpful 🙂
fastest way how to have the same env as on mac!
Excellent tutorial
thank you very much for this tutorial, it works fine !
awesome, thanks guys!
Hey, thank you so much for your clean comprehensive tutorial. Works well.
Thank you for this tutorial. It helped me to setup composer and php7 on windows 10 easlily and in a few steps.
Excelente!!!! Muchas gracias!
Great tthanks.
Really helpful ! Date as of now 10/4/2018 !!
thanks for the tutorial. worked great!
I really looked for this. Very simple and an excellent tuto. Thanks!
on 23-Feb-2019, this is still relevant and IMHO it is the easiest and best!
Many thanks! You article has resulted in an actually successful install of PHP and Composer as opposed to a frustrating headache plagued learning experience. Bless you.
Maaaaany thanks!! I was struggling with PHP installation :/ maybe I was doing another thing…