Sage theme as a package dependency in composer.json

I am using Bedrock Wordpress stack with composer and would like to define my theme (built with Sage) as a dependency in composer.json. Currently my highly customised Sage theme is a private git repository hosted on bitbucket.org.

I have watched the composer screencast and am very close to getting this working but there are errors running composer update when attempting to install the theme into theme directory.

The following code appears within the repositories array of bedrock composer.json and looks like this:

{
    "type": "package",
    "package": {
        "name": "name/name",
        "type": "wordpress-theme",
        "version": "1.0",
        "dist": {
            "type": "git",
            "url": "https://myname@bitbucket.org/myname/test-theme.git"
        },
        "require": {
            "composer/installers": "1.0"
        }
    }
}

The package name is also defined as required in bedrock composer.json:

“require”: {
“name/name”: “1.0”,
“php”: “>=5.4”,
“composer/installers”: “~1.0.12”,
“vlucas/phpdotenv”: “^2.0.1”,
“johnpbloch/wordpress”: “4.2.2”,
“wp-cli/wp-cli”: “^0.19.2”
},

The same code used to specify repository type and package details also exists within the composer.json file of my themes repo. When I run composer update in bedrock I get the following error:

Problem 1

  • Installation request for name/name `.0 -> satisfiable by name/name 1.0
  • name/name 1.0 requires composer/installers 1.0 -> no matching package

Potential causes:

  • A typo in the package name
    The package is not available in a stable-enough version according to your minimum stability setting

Could anyone please tell me where I am going wrong here?

You’ll need to specify something like ~1.0.12 for composer/installers required version. It should match up with this: https://github.com/roots/bedrock/blob/3081face47970c3f87a9469e571892d5422ffcbf/composer.json#L37

Thanks for coming back to me, although I still seem to be having issues using composer/installer ~1.0.12 the following error now occurs when running composer update:

[LoginException]
Downloader "Composer\Downloader\GitDownloader! is a source type downloader and can not be used to download dist.

Is there a working example of defining a wordpress theme git repository as a dependency in composer.json that I can take a look at?

I managed to find the solution here Best way to install private/paid plugins with Composer? - included good instructions for using bitbucket in composer.json.

1 Like