Drupal 8 Development Cookbook(Second Edition)
上QQ阅读APP看书,第一时间看更新

Installing a module or theme using Composer

Although it is not the required way to install an extension, this should become your default method. Why? Because each module is a dependency in your project, and each of those may have its own dependencies. Composer can manage dependencies for you, or you can manage them manually. Your time and capabilities probably will not grow to scale as well as Composer will. Not to mention, it also provides a standard way for PHP projects to interoperate and load classes.

You can get the Honeypot module and Bootstrap using the following two commands:

$ cd /path/to/drupal8
$ composer require drupal/honeypot $ composer require drupal/bootstrap

Here is an example of contributed projects, which require Composer for installation, because they leverage existing libraries in the PHP community at large:

  • Drupal Commerce
  • GeoIP
  • Search API Solr
  • Entity Print

As more and more modules integrate existing SDK libraries, the requirement to use Composer will increase.