ebsco / edsapi-drupal-plugin

A Drupal modules for the EBSCO Discovery Services API
Apache License 2.0
1 stars 3 forks source link

Install via Composer? #11

Closed jproctor closed 3 years ago

jproctor commented 6 years ago

Drupal 8 strongly encourages site owners to use Composer to manage dependencies. I’ve been trying to use it for our new site and am starting to really appreciate it. So far, this module is the only one I have that doesn’t use it.

  1. It needs a composer.json file. If the type specifies drupal-module, it’ll be installed correctly in modules/contrib/.

  2. It needs to be listed in a repository. Being an official contrib module at drupal.org might take more effort than you’re willing to invest, but packagist.org is free and easy.

  3. You will have to start tagging versions (and incrementing them when you want your customers to get new code). Might not be ideal while you’re still smoothing out some of the rough spots (though I’m pretty sure Composer allows numbered alpha- and beta-releases), but once you get it stabilized and start using branches for development, it’s a dream.

jproctor commented 6 years ago

(Aside: your installation instruction doc is wrong for D8. Modules now go in modules/, not sites/all/modules/.)

bmckinney commented 6 years ago

@jproctor great idea, thanks! give this a spin when you have a chance - we have commit hooks setup such that packagist is updated when a release is pushed out

jproctor commented 6 years ago

This change almost works.

I can install (files go into modules/contrib/edsapi-drupal8-plugin/ as expected), enable, and configure the plugin with no problems.

But when I try to place the block, it logs that it can’t find modules/custom/ebsco/src/Plugin/Block/EbscoBlock.php. Which is not where it should be looking for that file.

My best guess is that it wants the name in composer.json to be drupal/edsapi-drupal8-plugin instead of ebsco/edsapi-drupal8-plugin. In the meantime, I made a symlink from custom/ebsco/ to contrib/edsapi-drupal8-plugin/ and it seems to be working.

jameswilson commented 6 years ago

@jproctor, we have the module working fine installing it with:

composer require ebsco/edsapi-drupal8-plugin: ^0.2.0

If you're using https://github.com/drupal-composer/drupal-project as a baseline for your composer.json file on your Drupal project, then it should know what to do to place the module in the correct place in modules/contrib/edsapi-drupal8-plugin/

As for placing the block, I haven't been able to test that, but it almost feels like a separate issue, or a caching issue from having installed the module manually into the wrong folder previously.

Edit: If you don't use the composer.json recommended by the drupal-composer/drupal-project then you need to add a dependency on:

"composer/installers": "^1.2"

and add a section to explicitly tell the different drupal types where to be installed:

"extra": {
    "installer-paths": {
        "web/core": ["type:drupal-core"],
        "web/libraries/{$name}": ["type:drupal-library"],
        "web/modules/contrib/{$name}": ["type:drupal-module"],
        "web/profiles/contrib/{$name}": ["type:drupal-profile"],
        "web/themes/contrib/{$name}": ["type:drupal-theme"],
    },
}
kelsonthony commented 3 years ago

$ composer require ebsco/edsapi-drupal8-plugin