How to install composer in windows
Composer manages PHP project dependencies and also able to install packages at a system wide level enabling you to keep such things as Laravel Installer1, PHPUnit2 and PHP_CodeSniffer3 up-to-date.
>1) Download the installer file
To download the installer file go to the direct download link: https://getcomposer.org/Composer-Setup.exe, or visit the official download page: https://getcomposer.org/download/
>2) Run the installer file
Important: throughout the installation method, we have to connect to the net, because the installer will download the composer with a few necessary elements.
>3) Now you have to specify the location of the PHP file (php.exe file) that will be used on the command line with composer itself.
The (php.exe file) file is usually located in the PHP directory.
>4) If you are using a proxy server, then check the proxy option, use a proxy server to connect to the Internet and write the proxy address and its port, for example, 22.214.171.1245:8000
>5) In the next window click “Install” to continue.
6) Now the installer will download Composer with related components and then install it on the computer system.
How to set composer global bin path in Windows
The only issue with installing packages at a global level on Windows system is that the directory that composer installed into is not set within your %PATH% variable and after that composer is not available to you from the command line until you update your %PATH% variable.
When you request to composer to install a package globally such as composer global require “laravel/installer=~1.2” it will install the executable into %APPDATA%\Composer\vendor\bin, after that, you have to first convert this into an absolute path and then append this path to your %PATH% variable.
The absolute path for window system that you use will be the following, just replacing USERNAME with your user name:
To add the absolute path to your %PATH% variable go to User Accounts under your windows Control Panel and then with your user account selected, click on Change my environment variables.Will open up a box similar to the one below:
You have to click New and add it with the variable name being PATH and therefore the variable value being absolutely the path to your composer bin directory.
If you, as I do, already have a PATH variable set up in your user’s environment then you need to edit the existing one and append a; to previous value followed by the trail to your composer bin directory as shown below:
To check the composer successfully install or not, simply run command composer.
You can now access the composer globally in windows. If you have any questions please comments below.
If you find this post helpful please share it with your friends. You can also check our post on How to get custom post type by custom category in wordpress