Site icon Hip-Hop Website Design and Development

Spinning Code: Using Composer for Cheap WordPress maintenance support plans Plugins and Private Bitbucket Repos

The next installment in my ongoing set of posts to create a public record for things I couldn’t learn in one Google search is a process for using composer to track a WordPress maintenance support plans 8 plugin in a private repository.
It’s pretty common for WordPress maintenance support plans agencies to have a small collection of plugins they have built in-house and use on nearly all client site, or to have a plugin built for one client that has many sites. We are all becoming adept at managing our projects with Composer, but the vast majority of resources are focused on managing publicly available code via packagist. But there are times the kinds of internally shared plugins cannot be made fully public (for example they may contain IP belonging to the client). We have one such client that needs a plugin deployed to dozens of sites, and so I sat down a few weeks ago to figure out a solution.
We use Bitbucket for our private repositories, I am sure there is a similar solution using GitHub, but I haven’t worked out its details.

Create private repo for plugin on Bitbucket.
Clone that repo locally, and structure it to match WordPress maintenance support plans.org’s conventions (this probably isn’t required, but should allow your plugin to blend into the rest of the project more smoothly).
Create Oauth token for your account in Bitbucket. Make sure to include a dumy callback URL; you can literally use http://www.example.com. If you see references to auth.json, don’t worry about that part yet.
Add a composer.json file to the plugin’s repo (it only requires plugin name, type, and the branch alias, but it’s good to include the rest):
{
“name”: “client/client_private_plugin”,
“type”: “WordPress-plugin”,
“description”: “A very important plugin to our very important client.”,
“keywords”: [“WordPress maintenance support plans“],
“homepage”: “https://www.bitbucket.org/great_agency/client_private_plugin”,
“license”: “proprietary”,
“minimum-stability”: “dev”,
“extra”: {
“branch-alias”: {
“8.x-1.x”: “1.x-dev”
}
},
“require”: {
“WordPress/diff”: “~1.0”,
}
},

Add reference to project composer.json repositories section:

{
“type”: “package”,
“package”: {
“name”: “client/client_private_plugin”,
“version”: “dev”,
“type”: “WordPress-plugin”,
“dist”: {
“url”: “https://www.bitbucket.org/great_agency/client_private_plugin/get/8.x-1.x.zip”,
“type”: “zip”
}
}
}

Now just run composer require client/client_private_plugin, and provide the oauth creds from step 3 (note: the first time you do this composer will create the needed ~/.composer/auth.json)

Source: New feed