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.
- Download: VC_redist.x64.exe (64 bit) or VC_redist.x86.exe (32 bit)
Once downloaded, run the installer and click Install.
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.
3. Download and Install Composer
- Download Composer-Setup.exe from the Composer Download page.
In the second step of Composer Setup, make sure the correct path to php.exe is set and click Next.
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.
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.
In System Properties, click Environment Variables.
In System Variables, click Path and then click Edit.
Click New, type the path to your PHP folder (c:\php7
) and click OK.
Close the System Properties dialogue by clicking OK.
6. Test Composer
Open up Command Prompt and type composer -V
(that’s uppercase V).
If all was installed correctly, you should see a version number.
Hurrah! You can now run Composer and PHP on Windows 10.
Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.
Thank you.
The explanation was clear and it was executed at once.
Thank you SO much
Nice nice. Many thanks
Very helpful for a newbie, thank you.
Thank you
Muito Obrigado
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?
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!
thanks.
thank you.
Thank you it helps
Thank you.. it was really helpful
Thanks, it was helpful for such a newbie like me 🙂
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.
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…
Sounds like a Windows issue with permissions or firewall or something.
Did you run the install as Administrator?
I dug for this answer for many hours without success.
Finally I disabled my Bitdefender firewall, and was able to install Composer.
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
Thank you man,worked like magic
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
Make sure you do the cmd “run in administrator”. I was the same as you, so I ran in administrator and it worked.
IT was of Great help, Clear and easy, Thank you, it made my day
Thank you for your tutorial. Super clear and very helpful!
Thank you!
sysdm.cpl file not running is there any problem with my system pc . or any thing else
it works, Thanks for your clear tutorial
Thanks a ton!
Pretty detailed tutorial. I don’t know anything PHP related … yet it worked for me 🙂
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?
Have you tried opening CMD in administrator mode before running the commands? Is this the first time you’ve installed PHP on Windows 10?
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.
Delete PHP.
Extract https://windows.php.net/downloads/releases/php-7.4.4-nts-Win32-vc15-x64.zip to c:/php7 and then run in CMD
then
Does it work? If so, install Composer and tell it PHP is installed in c:/php7/php.exe
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.