Add Roots theme

How to add Roots theme via composer.json? I followed instructions on http://roots.io/wordpress-plugins-with-composer/

I put this under repositories, but getting Nothing to install or update on composer update command:

{   
      "type": "package",
      "package": {
        "name": "roots/roots",
        "version": "master",
        "type": "wordpress-theme",
        "dist": {
          "type": "zip",
          "url": "https://github.com/roots/roots/archive/master.zip"
        }   
      },  
      "require": {
        "php": ">=5.3.2",
        "composer/installers": "v1.0.6"
      }
    }

Always come up with solution upon asking a question lol

This post helped: http://matgargano.com/modern-wordpress-development-composer/

My mistakes are well obvious…

You’ve got to include the package in the require section:

{   
      "type": "package",
      "package": {
        "name": "roots/roots",
        "version": "master",
        "type": "wordpress-theme",
        "dist": {
          "type": "zip",
          "url": "https://github.com/roots/roots/archive/master.zip"
        }   
      },  
      "require": {
        "php": ">=5.3.2",
        "composer/installers": "v1.0.6",
        "roots/roots": "master"
      }
    }

Edited to add: just note it’s not the require for the package but the require at the end for the project as a whole.

My working template is:

...
{
      "type": "package",
      "package": {
        "name": "name_goes_here",
        "version": "dev-master",
        "type": "wordpress-theme",
        "dist": {
          "type": "zip",
          "url": "https://github.com/roots/roots/archive/master.zip"
        }
      },
      "require": {
        "php": ">=5.3.2",
        "fancyguy/webroot-installer": "1.*"
      }
    }
  ],
  "require": {
    "php": ">=5.3.2",
    "wordpress": "3.8.1",
    "fancyguy/webroot-installer": "1.1.0",
    "composer/installers": "v1.0.6",
    "wp-cli/wp-cli": "v0.13.0",
    "vlucas/phpdotenv": "~1.0.5",
    "same_name_goes_here": "dev-master"
  },...

Also it means you can put any theme, I just wanted to start with Roots. Just change dist:url to place where you hold your own theme (based on roots for example)

Including "type": "wordpress-theme" should install it into the correct directory for you.

I’ve just started using both Roots and Composer so I’m rather new to this. With that being said I have been able to get everything to work with the exception of being able to install Roots into my theme folder. Would appreciate any help.

{
"repositories": [
    {
        "type": "package",
        "package": [
            {
                "type": "webroot",
			    "name": "wordpress/wordpress",
			    "version": "3.8.1",
			    "dist": {
				    "url": "https://github.com/WordPress/WordPress/archive/3.8.1.zip",
				    "type": "zip"
			    },
			    "require": {
				          "fancyguy/webroot-installer": "1.0.0" 
			    }
            },
            {
                "type": "wordpress-theme",
                "name": "roots/roots-sass",
                "version": "6.5.1",
                "dist": {
                    "url": "https://github.com/roots/roots-sass/archive/6.5.1.zip",
                    "type": "zip"
                },
                "require": {
				    "fancyguy/webroot-installer": "1.0.0" 
			    }
            }
        ]
    }
],    
"require": {        
    "wordpress/wordpress": "3.8.1",
    "roots/roots-sass": "6.5.1"
},
"extra": {
	"webroot-dir": "wp",
        "webroot-package": "wordpress/wordpress",
        "installer-paths": {
              "app/themes/{$name}/": ["wordpress-theme"]
        }   
}

}

Unless you’re using Roots as a parent theme, you shouldn’t really be doing this. But I’ve given an example at the gist below anyway:

Don’t forget to add Roots (or any theme you’re adding) to the requires (see line 75).

Your problem is leaving out type:wordpress-theme:

"app/themes/{$name}/": ["type:wordpress-theme"]

This might seem like a silly question but what then would be the ideal way of installing Roots in a Bedrock based project? I just git cloned roots then I ended up with a submodule in my main project.

You just need to delete the .git/ directory from the theme directory.

1 Like