Dealing with, or joining, two composer files

I’m using Trellis, Bedrock, and sage-twig-theme.

Now Bedrock has a composer.json file (which automatically gets run at deployment time) but the theme also has one.

I can’t just require the theme with composer because it’s heavily edited.

What’s the best thing to do in this situation? Can I easily combine the two files, and have the various dependencies still installed to places where they’re found properly? Or do I need to add something to the ansible scripts to make it run composer install in both locations?

This is something I unfortunately just learned the other day from @QWp6t .

If you add a Composer package, you expect it to get all dependencies from that package. Makes everything easy and wonderful.

However, wordpress-theme and wordpress-plugin types of Composer packages are not the same, the dependencies of the theme area not gotten automatically, even if you use Composer from the Bedrock project to load the theme.

This is a huge bummer. It’s a reason that WP itself needs proper Composer integration, but apparently isn’t going anywhere anytime soon.

To be honest, I don’t know what the current best solution is. I would add all dependencies with the Bedrock (or app)'s Composer file… and keep it to that. Load as much as regular Composer packages as possible.

So you’re saying move all the dependencies from the theme’s composer file into the root composer file? Will things still get installed to the right places?

What dependencies do you mean?

Composer packages are autoloaded and can be used anywhere.

If you mean WordPress plugins, then yes, those should never be installed with the theme… those should be installed with the Bedrock Composer file, as plugins are intended to be installed from the “app” portion.

Well here’s sage-twig-theme’s composer.json file:

  "name": "rabota/sage-twig-theme",
  "description": "Starter theme - mix of Sage and Timber theme",
  "minimum-stability" : "stable",
  "authors": [
          "name": "Vincent Kranenodnk",
          "email": ""
  "extra": {
  	"installer-paths": {
      "../../plugins/{$name}/": [
  "require": {
	  "wpackagist-plugin/timber-library": "*"
  "repositories": [
      "type": "composer",
      "url": ""

It looks to me like that’s saying to install Timber to outside the theme directory. So hopefully I can just move the dependency line to the other composer.json file and I’ll be done. I’ll try it…

Um, yeah… I wouldn’t call this a good idea. It’s saying to install the Timber plugin in the plugins directory, but going up out of the theme directory and into the plugins directory…

This is the issue I’m finding right here, and I’m not sure what a great solution is at the moment. We shouldn’t have to move the Timber plugin to the app, it should be seen and installed automatically. But it’s not.

Yes, I would suggest just moving the timber library plugin to your Bedrock Composer file…

Yup, that’s what I’ve done, and it works with no other changes. So what I did was this:

  1. Copy the line "wpackagist-plugin/timber-library": "*" from the theme’s composer.json file to Bedrock’s one (I actually updated it with a specific version range)
  2. Remove theme’s composer.json, composer.lock, vendor directory
  3. Remove references to those from theme’s .gitignore (I don’t like loose ends)
  4. Run composer update in the Bedrock directory

I see what you’re saying about a better solution to installing themes’s dependencies. But in this case I think it’s okay to manually move the dependencies up to the Bedrock level, since the modified theme is now part of my application, rather than just another plugin.

Thanks for your help!