In this article, I will be showing you how you can setup a local development on Windows 10 with WAMP, Composer and Git.
First thing you want to do is to install WAMP. I will skip the WAMP installation since you can follow this guide: https://duvien.com/blog/setting-local-development-server-wamp-windows-10
If you have not yet installed Notepad ++, I recommend you do this: https://notepad-plus-plus.org/downloads/
Once you have setup WAMP, come back to this article and carry on.
Installing both Composer and Git is pretty straightforward on Windows compare to other operating systems.
We will start of by installing and setting up Git and then lastly, Composer.
Installing Git on Windows 10
Git is a distributed version-control system for tracking changes in source code during software development.
Download Git from: https://git-scm.com/downloads and run the installer.
During the installation process, choose these settings as shown in the screenshots below:
Once you have completed installing Git. Fire up the Git Bash command line. In the taskbar search, type: Git Bash
Let see if Git is working. In your Git Bash, type: git
This should print out a help guide on your Git Bash. If you type: git --version
It should print out the version number.
For a list of Git commands, see: http://guides.beanstalkapp.com/version-control/common-git-commands.html
Great we now have Git on Windows 10 to use.
Installing Composer on Windows 10
Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
During installation, you will have a list of PHP version to select from (these are installed from WAMP). I just went with PHP 7.4.9 though it is up to you which version you choose since Composer works with any. Which PHP version does Composer run best with? I'm not sure, never had any issues with PHP 7 though. Perhaps someone can leave a comment if they know the best recommended PHP version for Composer and why?
Quick note: If plan on installing Drush 8 to use with Drupal 7 (see last section at the end of this article), then you should choose PHP 5.6.x because Drush will default to whichever PHP you have selected with Composer. If you have already
Skip the proxy setup (leave blank) and carry on to complete the installation.
To test if Composer is working, open up a command line and type: composer
You should see this in your command prompt.
If composer is not working you need to enable the following PHP extensions: php_openssl, php_curl, php_socket (for the PHP version you have choose for Composer)
Left-click on mampmanager icon -> PHP (version) -> PHP extensions
Click on openssl to enable it (a green check icon should appear next to it). Do the same for curl and socket.
For a list of Composer commands, see: https://getcomposer.org/doc/03-cli.md
That is all there is to it. Enjoy.
Oh! one more thing...
If you are developing with Drupal 7, you might want to install Drush (a command line shell and Unix scripting interface for Drupal). Here is an excellent article: http://modulesunraveled.com/drush/installing-drush-windows It will show you how to install Drush 7 but we want Drush 8, so use this instead:
composer global require drush/drush:8.*
Please note: Drush 8 only supports Drupal 7 and earlier versions of Drupal 8. From Drush 9 onward, it only supports Drupal 8.5+ and 9+. But this is okay, you can install Drush to run inside of your Drupal installation for Drupal 8.5+ or 9+ using Composer.
Quick note: If you have already chosen PHP 7.4.9 during the Composer installation process but now want to use 5.6.x instead, you can still change the path.
On Windows 10:
control panel -> system -> in the left panel click on 'Advanced system settings' -> Environment variables
In the System variables section, look for 'Path' under 'variable' column. Select this can click on edit button. You will see a line: c:\wamp64\bin\php\php7.4.9
change the value of the php7.4.9 to the PHP version you want to use, for example: replace it with php5.6.30. Please be aware, if you are working with Drupal 8 or 9, you need to change it back to php7.4.9 so that it will work with some dependencies that requires it.
If plan only to do development on Drupal 8 and 9, then use this guide instead: https://medium.com/d6-digital/installing-drush-on-windows-10-for-drupal-8-22f7f7c38f2