Drupal 8 development with Composer and Drush

By Arun AK, 21 May, 2017

Drupal 8 has made lot of improvements from Drupal 7. There are some bigger API changes and have incorporated with many good practices in the website development.

In Drupal 8 Composer is using for dependency management. It would very helpfull at the time of development. For example if we need to install panels module in our D8 site, first we need to download panels module from drupal.org and the need to extract the zip in to modules folder. As Panels module is depends on Ctools module need to download Panels module and extract it in to modules folder. When we install plugins manually we need install its dependency also separately.

In this case Composer and Drush will make development easy. Drush is a command line shell and Unix scripting interface for Drupal.

Download Drupal

Following command will download and extract drupal in to www_d8test2_com folder. Then you can directly access your website in your localhost through http://localhost/www_d8test2_com url.
composer create-project drupal/drupal www_d8test2_com

Set composer repository for Drupal 8

To manage dependency of your Drupal 8 project you have set up the composer repository like below:

$ composer config repositories.drupal composer https://packages.drupal.org/8/

Install Drupal using Drush

Following drush command will install drupal on server. So that you can skip the manual installation process which need to run through browser.
drush site-install standard --db-url="mysql://root@localhost/www_d8test2_com" --site-name=www.d8test.com --account-name="admin" --account-pass="123456"