Roots Discourse

Including Soil via composer.json


Is there a way that I can automatically download Soil during npm install? I tried:

“require”: {
“php”: “>=5.5.0”,
“composer/installers”: “~1.0”,
“roots/soil”: “3.7.1”

but no luck. Can you point a noob in the right direction?



soil is not a npm plugin, it’s a composer plugin. So you need to run composer install not npm install.
Put this in your composer.json and it should work normally:

"require": {
    "php": ">=5.6",
    "composer/composer": "~1.0.0@dev",
    "composer/installers": "~1.0.25",
    "vlucas/phpdotenv": "^2.0.1",
    "johnpbloch/wordpress": "~4.5",
    "oscarotero/env": "^1.0",
    "roots/soil": "^3.6.2"

Also, which composer.json are you editing?



I’m editing the composer.json file in the theme folder, using a default Wordpress install.

When I use the code below to install, it creates a “wp-content/plugins/soil” directory, so running it from the plugins folder doesn’t work. When I try to run it from the root, it creates extra composer and vendor files.

composer require roots/soil 3.7.1

What directory should I be in to use the composer script above? It seems like it might be setup for a Bedrock directory structure, which I’m not using it yet.

Is there a way to edit an existing composer.json file with the script below, then save and have the plugin install in the plugins folder in a default Wordpress install?

"require": {
        "roots/soil": "3.7.1"


In its composer.json file Soil sets it’s “type” to wordpress-plugin.

The following lines from Bedrock’s composer.json file:

tells Composer (via the composer-installers package) where to install Soil to.

Without this Soil will install to the default plugin location used by WordPress which is wp-content/plugins/soil.

You can install Soil using Composer if your WordPress project has been set up to use Composer, like Bedrock is, from the root of your project.

This would be a separate composer.json file to the one you have in your theme.



Ah, I see… thanks for the clarification.