Setup Drupal 8 module using Composer

Drupal uses an externally-maintained repository the https://packagist.drupal-composer.org but this repo is scheduled to be deprecated in January 2017 by then we will be using https://packages.drupal.org/8 repo URL.

It is assumed that composer is already installed in your system. Make sure your composer version is 1.0.0 or higher, to check execute:

  
composer -V
  

If it is lower than version 1.0.0, update it by:

  
composer self-update
  

Change directory to your Drupal root path.

Since we are getting our module in external composer repository, configure composer to look up to its repo URL:

  
composer config repositories.drupal composer https://packagist.drupal-composer.org
  

Note: on January 2017, you will want to change to new repo:

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

Finally, to install a Drupal module (lets setup Smart IP) execute:

  
composer require "drupal/smart_ip ~8.3" -vvv
  

Smart IP module has two non-Drupal module dependencies: geoip2/geoip2 and ip2location/ip2location-php libraries. These two libraries should be downloaded automatically.

The module will be installed at [drupal root path]/module/smart_ip

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.