Drupal 8 Composer on Win 10
Getting Drupal 8 with Composer Running on Windows 10
I am doing this quick write up because I had a lot of trouble getting a local Drupal 8 started on my Windows 10 machine using composer. This is more of a snapshot of what you’ll need to get setup.
- Dev Desktop by Acquia - You could also use something like XXAMP.
- Composer Run the installer they have.
Install Dev Desktop
I don’t need to go into much detail here but just run the installer verify you can get a new Drupal Site up and running. You can create a new site and select the Drupal 8 option, but this is not the correct Drupal we want. We want to manage our Drupal 8 via Composer, so things are not that simple.
Add PHP and MySQL to your Environment Path
Press the ‘windows key’ and type in “Env” and you should find the setting to edit you Path/Environment Variables.
Add the PHP and MySQL executables to your path.
- C:\Program Files (x86)\DevDesktop\mysql\bin
- C:\Program Files (x86)\DevDesktop\php7_0
SPOILER Having MySQL in your path was the missing piece that I spent hours trying to solve. If its missing you will get errors like
The filename, directory name, or volume label syntax is incorrect.
Run the installer at getcomposer.org/download and it should be straight forward.
Install Drush from Composer
Now that you have composer, fire up a new command line. I use cmder and run the following command to install Drush.
composer global require drush/drush:8.*
Grab the Drupal 8 Composer Project
Head over to the Drupal Composer Project on Github and run the
composer create-project.. command and follow their steps. I believe I also had to run a
composer install after I created the project.
Point Dev Desktop to your Drupal 8 Composer Site
Fire up Dev Desktop. Create a new site and choose the option Import Local Drupal Site navigate to your Drupal 8 Composer Project and choose the
Run The Site Installer
Not sure if this is needed or not, but I fired up the Dev Desktop URL for the site, and ran through the site installer until I got to the standard Drupal 8 homepage.
Move Dev Desktop Database Settings to settings.local.php
Another tricky issue is Drush won’t be able to find the
<DDSETTINGS> which it adds to your sites settings.php file. So I enabled/uncommented the
settings.local.php lines in settings.php and located the Dev Desktop include (located for me at
C:\Users\username\.acquia\DevDesktop\DrupalSettings\loc_d8_dd.inc) and copy and pasted the contents of that include into my settings.local.php.
If you get errors like
Command config-list needs a higher bootstrap level to run - you will need to invoke drush from a more[error] functional Drupal environment to run this command. The drush command 'cli' could not be executed.[error] Drush was not able to start (bootstrap) the Drupal database.[error]Drush is probably not able to find your database info, try pasting the Dev Desktop database settings directly into settings.php to troubleshoot the issue.
Test your Command Line Tools
Run the following to make sure Composer, PHP, and MySQL are added to your path correctly.
- PHP -v
- MySQL then type quit to exit
- drush version
Drush Should Work!
You now should be able to run Drush commands such as