I have a site-specific module in my modules directory that's being loaded in config/app.php. Since it won't be used elsewhere I am not storing the module in an external repository.

When I added a composer.json file to load some dependencies for the module and ran composer update, it created a new vendor directory inside the module directory.

Is there a way I can have a composer.json inside that module directory, but have the dependencies loaded in the main vendor directory?

Or am I doing something totally wrong here?

  • If I'm following you correctly, can't you just set the vendor-dir config param of your module's composer.json file? getcomposer.org/doc/06-config.md#vendor-dir
    – Brad Bell
    Commented Jan 16, 2018 at 21:19
  • I guess what I'm getting at is that with a plugin that's been loaded via composer require, all the dependencies for the plugin get loaded automatically. I'm looking to get the dependencies for the module to bubble up to the whole project, so when I run composer update for the whole Craft install it automatically grabs the dependencies for the module as well, as it would for a plugin. Commented Jan 16, 2018 at 22:01
  • 1
    You should be able to add your module as a Composer dependency from your main composer.json (using path since it's probably not public). Then composer updateing your main one should take the module and its dependencies into account.
    – Brad Bell
    Commented Jan 16, 2018 at 23:54
  • Yup that did it. Commented Jan 16, 2018 at 23:55
  • 1
    Awesome... if you add that as an answer I'll give you 10 shiny new reputation points!
    – Brad Bell
    Commented Jan 16, 2018 at 23:56

1 Answer 1


With a little nudge from Brad, here's the answer:

In order to get the module's composer dependencies taken into account in the parent site's composer dependencies, you need to add the module in the parent's composer.json, both as a require and as a repository with the path type, like so:

  ... a bunch of stuff from the default composer.json goes here ...
  "require": {
    "php": ">=7.0.0",
    "craftcms/cms": "3.0.0-RC5",
    "vlucas/phpdotenv": "^2.4.0",
    "roave/security-advisories": "dev-master",
    "modules/modulename": "dev-master" <-- add your module here (package name)
  ... more stuff goes here ...
  "repositories": [
      "type": "path",
      "url": "modules/modulename" <--- and add it here (package path)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.