I’ve created a simple test wordpress plugin. The plugin consists of a single php file (kreplach.php) and a composer.json:
kreplach.php
<?php
/*
Plugin Name: kreplach
Plugin URI: http://gitlab.example.com/sales/kreplach
Description: just a test
Author: Foo Bartok
Version: 1.0
Author URI: http://example.com
*/
?>
composer.json
{
"license": "MIT",
"name": "sales/kreplach",
"type": "wordpress-plugin",
"description": "just a test",
"authors": [
{
"name": "Foo Bartok",
"email": "foo@example.com",
"homepage": "example.com"
}
],
"require": {
"composer/installers": "*"
}
}
On my dev server I have the following composer.json
Server’s composer.json
{
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
},
{
"type": "vcs",
"url": "git@gitlab.example.com:sales/kreplach.git"
}
],
"require": {
"php": ">=5.4",
"wpackagist-plugin/akismet": "*",
"wpackagist-plugin/contact-form-7": "*",
"wpackagist-plugin/wordpress-importer": "*",
"sales/kreplach": "master",
"johnpbloch/wordpress": "4.*",
"composer/installers": "*"
},
"extra": {
"wordpress-install-dir": "wp"
}
}
What I think SHOULD happen:
- Composer looks through the git repo for composer.json
- Composer matches the name “sales/kreplach” found in the build host’s composer.json
- Composer copies the contents of the master branch into
wp-content/plugins/kreplach
on my build host. - My fake plug-in does nothing, as designed.
What actually happens:
Bitter, bitter failure.
Loading composer repositories with package information Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package sales/kreplach could not be found in any version, there may be a typo in the package name.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
I have tested cloning the sales/kreplach
repo onto the same host I’m attempting to install the plugin on.
To make sure that composer is actually reading the composer.json file from the git repo, I introduced a typo (yeah, totally on purpose, like) which threw a “hey, this json file is broken, Foam Head” error.
My version of gitlab is omnibus edition 8.6.4 (installed today).
I have successfully done this same sort of trick with pip/requirements.txt to install custom python modules, so I’m not unused to following directions. Am I missing a step, or some sort of non-obvious (to me at least) nomenclature?
Update 2021, 5 years later, since GitLab 13.3 (Aug. 2020), GitLab (even in its free edition) has a Package Registry, establishing GitLab as a private repository.
You can publish in it Composer packages, and, with GitLab 13.11 (April 2021):
And (still GitLab 13.11, April 2021):
I’ve not used gitlab but have used this method quite a bit with Bitbucket and GitHub.
You need to specify
"sales/kreplach": "dev-master"
in the server’s composer.json – note that the branch name must be prefixed with “dev-“.Apparently Composer has special support for GitHub and BitBucket, which may not exist for Gitlab…so you may need to specify
git
as the repository type rather thanvcs
.Good luck!
Refs: