Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Installing Drupal Console on Windows

Parent Feed: 

The Drupal Console has become a great command-line tool for managing Drupal 8 sites. In our Drupal 8 Module Development Trainings, we use it to automatically generate boilerplate code, so our trainees can get a quick start! Even though Drupal Console has been out for just one year, it already has over four hundred thousand downloads.

Unfortunately, getting Drupal Console running on Windows can be quite difficult. So we thought we'd help! We helped fix Drupal Console's integration with Acquia Dev Desktop on Windows, and we wrote this step-by-step guide to help you get it working too.

Getting started

To follow this guide, you'll need the following:

  1. A recent version of Windows. I've done my testing on Windows 10, but Vista or newer should work.
  2. An installation of Acquia Dev Desktop. It's typically installed in C:\Program Files (x86)\DevDesktop, so if you installed it at a different path, you may have to alter these instructions.

Watch out if you've installed other web development or command-line environments in Windows—they might interfere. For these instructions, make sure in particular to only use the command-line that Dev Desktop gives you, and no other. Try to run Drupal Console in its own command-line window, since other commands might modify your command-line's environment.

Installation steps

  1. We'll need to use a recent version of PHP for Drupal Console to work. Open Dev Desktop, select Acquia Dev Desktop ➡ Settings. On the Config tab, set the Default PHP version to the recommended version of PHP 7, such as PHP 7.0.x.Set default PHP version
  2. Drupal Console works with Drupal 8 only, so you'll need a Drupal 8 site to work with. If you already have a working Drupal 8 site in Dev Desktop, just make sure it's using PHP 7.0.x.

    If you don't have a Drupal 8 site, install one with Dev Desktop. Click+ ➡ New Drupal site…and use the latest version of Drupal 8. Choose whatever site name and database settings you like, the defaults are probably fine—but make sure to use PHP 7. Once the site is finished downloading, visit the site and follow the Drupal installation process.

  3. Since Console is a command-line tool, we'll need to use a command line to run it. Even if you have one open already, it's safest to open a brand new one. You can get a Windows console for your site by clicking the Open Drush console button in Dev Desktop:

    Console button

  4. We'll be using Composer to install Drupal Console. Unfortunately, Dev Desktop installs Composer in a strange way, and just running composer does not work. We'll have to modify its batch file by running the following command:

    echo @php "C:\Program Files (x86)\DevDesktop\tools\composer.phar" %* > "C:\Program Files (x86)\DevDesktop\tools\composer.bat"
    

    Note: To run a command, just copy it from this webpage, paste it into your command-line window, and press Enter. Or if it's short, you can just type it in and then press Enter.

  5. Now let's finally install Drupal Console. We need to use a pre-release version, since 1.0 isn't ready. Make sure your current directory is your site root, and then run the following:

    composer require drupal/console:">=1.0-rc15" --prefer-dist --optimize-autoloader --sort-packages
    

    This will download Drupal Console and all its dependencies.

  6. Let's test out Drupal Console! Run:

    vendor\bin\drupal site:status
    

    You should see a list of information about the site. If that doesn't happen, check out our troubleshooting steps.

  7. To make it easier to run Drupal Console, we can install the Drupal Console Launcher. First, download the launcher:

    php -dopenssl.cafile= -r "readfile('https://drupalconsole.com/installer');" > "C:\Program Files (x86)\DevDesktop\tools\drupal.phar"
    

    Then, create a batch file so we can run this easily:

    echo @php.exe "C:\Program Files (x86)\DevDesktop\tools\drupal.phar" %* > "C:\Program Files (x86)\DevDesktop\tools\drupal.bat"
    

    Now you should be able to just run drupal site:status from anywhere inside your site root, and it will automatically find and run the Drupal Console.

  8. If you want Drupal Console to work on another Drupal site, you'll need to install Console again for that site. Don't forget to make sure the site is using PHP 7!

Troubleshooting

Did something go wrong? Our troubleshooting page might help you figure out what happened.

If that still didn't help, let us know! Email us, or leave a comment on this post. Please point us to a Gist containing the complete log of what happened at the command-line, so we can diagnose the problem, and update our instructions.

Where to go next?

If these instructions worked for you, spread the word! We want to get as many people as possible using Drupal and Drupal Console. Also let us know if there's another Drupal environment for Windows that you'd like instructions for—Bitnami? XAMPP? Something else?

Once you have Console working, there are a ton of interesting things you can do with it! Here's some great blog posts other people have written to help you learn more:

Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web