Composer and wpackagist commercial plugins

With composer and wpackagist sometimes you want to include a package that isn’t listed nor does it have a composer.json file. This could be a commercial plugin or something else that might live in a repo or a zip somewhere on the web. It seems like information for this would be fairly easy to find but from what I could tell there wasn’t anything to connect all the dots for doing this. I’ve noticed that most people will include the publicly available ones in their composer file and leave everything else out leaving other engineers to scramle together finding the dependancies they need and installing them manually. This leaves me to believe that they have given up on finding a solution to the problem otherwise they would just include it in the first place.

It turns out it’s relatively straightforward but the information is disjointed and difficult to find. The trick is you have to define the package from within your composer file. They will then be included as wpackagist plugins just the same as public ones.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{
"name": "the-project-name",
"type": "wordpress-theme",
"require": {
"wpackagist-plugin/wordpress-importer": "0.6.1",
"wpackagist-plugin/gravity-forms-custom-add-on": "1.0",
"wpackagist-plugin/gravity-forms": "1.0"
},
"repositories": [
{
"type": "composer",
"url": "http://wpackagist.org"
},
{
"type": "package",
"package": {
"name": "wpackagist-plugin/gravity-forms-custom-add-on",
"version": "1.0",
"type": "wordpress-plugin",
"source": {
"url": "git@github.com:name/gravity-forms-custom-add-on.git",
"type": "git",
"reference": "origin/master"
}
}
},
{
"type": "package",
"package": {
"name": "wpackagist-plugin/gravity-forms",
"version": "1.0",
"type": "wordpress-plugin",
"dist": {
"url": "https://github.com/name/gravity-forms/archive/master.zip",
"type": "zip",
"reference": "master"
}
}
}
],
"extra": {
"installer-paths": {
"plugins/{$name}": [
"type:wordpress-plugin"
]
}
}
}