we can add a github repo as below then run composer install
"config": {
"allow-plugins": {
"composer/installers": true
}
},
"repositories": [
{
"type": "git",
"url": "https://github.com/tombenner/wp-mvc.git"
}
],
"require":{
"tombenner/wp-mvc": "dev-master"
}
without any issue, but given, we have a composer.json as:
"config": {
"allow-plugins": {
"composer/installers": true
}
},
"repositories": [
{
"type": "git",
"url": "https://github.com/sampoyigi/ti-ext-localepicker.git"
}
],
"require":{
"sampoyigi/ti-ext-localepicker": "dev-master"
}
when composer install
In RootPackageLoader.php line 160:
require.ti-ext-localepicker is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and packag
name can be words separated by -, . or _. The complete name should match "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a
z0-9]+)*$".
install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--download-only] [--dev] [--no-suggest] [-dev] [--no-autoloader] [--no-progress] [--no-install] [--audit] [--audit-format AUDIT-FORMAT] [-v|vv|vvv|--verbose] [-o|--optimiztoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-rGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>...]
how can we add a "package" using composer where it is available on github.
Your error would manifest itself when you have
"require":{
"ti-ext-localepicker": "dev-master"
}
in your composer.json
, not
"require":{
"sampoyigi/ti-ext-localepicker": "dev-master"
}
as you indicate in your original post. However, even with the second require
in your composer.json
, you should still get an error like:
[Composer\Repository\InvalidRepositoryException]
No valid composer.json was found in any branch or tag of https://github.com/sampoyigi/ti-ext-localepicker.git, could not load a package from it.
Since the repository has no composer.json
in its root, we would need to specify the metadata ourselves for Composer to be able to install it by using "type": "package"
with data in the "package"
key:
{
"config": {
"allow-plugins": {
"composer/installers": true
}
},
"repositories": [
{
"type": "package",
"package": {
"name": "sampoyigi/ti-ext-localepicker",
"version": "dev-master",
"dist": {
"url": "https://github.com/sampoyigi/ti-ext-localepicker/archive/refs/heads/master.zip",
"type": "zip"
}
}
}
],
"require":{
"sampoyigi/ti-ext-localepicker": "dev-master"
}
}