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.
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.
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…
Remove references to those from theme’s .gitignore (I don’t like loose ends)
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.