I had a similar problem: Beside adding a Git repository, I also wanted to include a SVN repository (that has no composer.json) and a ZIP file. The solution above did not work for me.
With Composer (version 1) I got following error message:
Problem 1 - The requested package XXX could not be found in any
version, there may be a typo in the package name.
Upgrading to Composer version 2 helped, since the error message was much more helpful:
Problem 1 - Root composer.json requires XXX *, found XXX[master] but
it does not match your minimum-stability.
So the solution is to add "@dev" behind the required version. Furthermore, I had to include "secure-http": false to the config section, because the ZIP file comes from a page that has no HTTPS.
Here is my full composer.json file:
{
"prefer-dist": true,
"repositories": {
"viathinksoft/vnag": {
"type": "package",
"packagist.org": false,
"package": {
"name": "viathinksoft/vnag",
"version": "master",
"license": "Apache-2.0",
"source": {
"url": "https://svn.viathinksoft.com/svn/vnag/",
"type": "svn",
"reference": "trunk/"
}
}
},
"dcodeio/bcrypt.js": {
"type": "package",
"packagist.org": false,
"package": {
"name": "dcodeio/bcrypt.js",
"version": "master",
"license": [
"BSD-3-Clause",
"MIT"
],
"source": {
"url": "https://github.com/dcodeio/bcrypt.js",
"type": "git",
"reference": "master"
}
}
},
"spamspan/spamspan": {
"type": "package",
"packagist.org": false,
"package": {
"name": "spamspan/spamspan",
"version": "master",
"license": "GPL-2.0-only",
"dist": {
"url": "http://www.spamspan.com/releases/spamspan-latest.zip",
"type": "zip",
"reference": "master"
}
}
}
},
"require": {
"dcodeio/bcrypt.js": "*@dev",
"viathinksoft/vnag": "*@dev",
"spamspan/spamspan": "*@dev"
},
"config": {
"secure-http": false,
"preferred-install": {
"*": "dist"
}
}
}
I would also like to explain why I am doing this:
These are examples of three third-party products which do not have composer.json file. I am aware that "bcrypt.io" is a npm project, and I could theoretically use npm to download it, and I could manually download and unpack the ZIP file in the postinstall part of composer.
However, I would like to have all dependencies in the vendor directory of my project, but I don't want to manually add something in this directory, because it is managed by composer. So I let composer handle everything.