How to install composer on windows and configure to work with Drupal


Go to the Drupal root directory ( e.g If you have installed XAMPP, It may be in c:/xampp/htdocs/drupal ) 


Inside that directory press ctrl+shift on keyboard and right click simultaneously to open a Command prompt window directly.


Type this command and press enter :                                                                                                                              php -r "eval('?>'.file_get_contents(''));"


Type this command and press enter :                                                                                                                               echo php "%~dp0composer.phar" %* > composer.bat


Your composer is successfully configured. You can execute any command now .

E.g to download a module and its dependencies execute this:

>composer require drupal/search_api_location 

>drush en search_api_location 

Remember the composer is not configured to access from any location i.e you have to access it by going to root directory always. e.g inside your Drupal root directory open the command window by pressing ctrl+shift+right mouse click and type any command like  " composer  update drupal/modulename " and press enter.

More Read: