Sunday, November 20, 2016

Drupal 8, Modules, Composer JSON, Platform.sh

In Drupal CMS we can integrate Modules in different ways like uploading module via module manager/ extent, manually copy pasting module folders, via Drush command, Drupal consol and Composer.

Most preferable ways are either via Drush or by Composer. Now we are sometimes confused what is best way to do that actually. My personal opinion is whatever procedure/ technique u've applied must reach the  requirement properly. I also prefer by Dursh or by Composer.
Now some modules has dependency on third party libraries. Drush is unable to load those vendor libraries.
Better explain through an example.
Lets consider about Address Module. Address has third party vendor/ library dependency and if we execute command like

$drush cr --continue-with-error/ --no-halt-on-error
$drush en Address -y

It'll successfully download the Address module but will throw error about Vendor dependency i.e. Address Module will not be enabled.

So, drush fails to enable Address module. Here we need Composer extensively. Composer checks the Module and its Vendors defined in composer.json file. So we need to execute commands like this -

$composer config repositories.drupal composer https://packages.drupal.org/8
$composer require "drupal/address ~1.0"

Similarly to add geoip Module we can execute this command.

 $composer config repositories.drupal composer https://packages.drupal.org/8
$composer require "drupal/geoip 2.x-dev"

Now what should we do when we are on Platform.sh ?
To be continued ...

No comments:

Post a Comment