Composer is a package manager for PHP, probably the most important and well known. I prefer containerizing as much as possible in my projects, but for ease of use in local developments, sometimes it’s easier to have package managers available directly in your command line.
Yes, I still sometimes use PHP for small personal projects, as a low hanging fruit to solve basic problems. I rarely run it without docker locally, but I still want to use it’s package manager without having to execute a command inside Docker – my preferred solution for containerization.
The first thing you need is php. On Windows, we will just download php and put it in program files:
- Get a thread safe version from https://windows.php.net/download
- Unzip the contents in
C:\Program Files\php
, to which you can optionally add the version name; - An optional step is to edit the
php.ini
config file and maybe enable some of the more useful extensions (e.g. the zip extension); - Use the Windows start button, then type
sysdm.cpl
- Go to
Advanced
andEnvironment Variables
; - Add the path to your folder in both
User variables
andSystem Variables
; - In the terminal, you should now be able to run
php -v
For composer, you should go to the download page and just run the installer you download, by selecting the path to your freshly installed php:
It’s not always needed, but a system restart might be the solution if php
and composer
are not available to you in your terminal. Windows has gone a looong way since it’s first versions, but still it keeps some of it’s old habits 😈
Read more:
- https://stackoverflow.com/questions/1623914/what-is-thread-safe-or-non-thread-safe-in-php
- https://www.pcworld.com/article/426973/why-your-pc-has-two-program-files-folders-and-why-one-of-them-is-x86.html
- https://stackoverflow.com/questions/19124930/php-the-term-php-is-not-recognized-as-the-name-of-a-cmdlet-function-script
- https://youtu.be/P8zMeCY2qtc
- https://youtu.be/pS0U-PsXUlg