Tag Archives: composer

How to Add a WordPress theme via composer with a Private GitLab Repository

I have been exploring using Composer for managing themes and plugins for WordPress. For public themes and plugins, this could not be easier using WordPress Packagist. However, I had a hard time finding a straightforward explanation for how to integrate a theme I am developing on a private GitLab repository.

It turns out that the solution is very simple. In your GitLab theme/plugin:

{
    "name": "<username>/<package>",
    "type": "wordpress-theme|wordpress-plugin",
    "require": {
        "composer/installers": "~1.0"
    }
}

Adding composer/installers as a require library allows you to set the type attribute to wordpress-theme or wordpress-plugin.

When you are including your theme/plugin in a composer file at your WordPress root, include these configurations:

{
    "repositories": [
        {
            "type": "git",
            "url": "git@gitlab.com:<username>/<package>.git"
        }
    ],
    "require": {
        "<username>/<package>": "<version>"
    }
}

Important: For a private repository, you need to add the private key beforehand by loading it into an SSH config file or using ssh-add.

Windows Users: I recommend using VVV for testing WordPress. If, however, you want to stick with Windows and a WAMP server, you can download Git-SCM and follow these instructions to add SSH keys. I was able to set up an SSH key when running Git Bash (not Git CMD). You can also run plink.exe by following the instructions.