How do you get composer to install a non-composer package?
Asked Answered
U

2

39

I am trying to get composer to download the following library from this project, however, it does not have a composer.json file in it so I'm not sure if this is possible.

{
    "require" : {
        "fguillot/picoFeed" : "*"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/fguillot/picoFeed"
        }
    ]
}

Error:

[Composer\Repository\InvalidRepositoryException]
No valid composer.json was found in any branch or tag of https://github.com/fguillot/picoFeed, could not load a package from it.

Unswerving answered 31/5, 2013 at 0:24 Comment(0)
R
76

To include a non composer repository you need to set up a package repository. Which would give you something like:

{
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "fguillot/picoFeed",
                "version": "dev-master",
                "source": {
                    "url": "https://github.com/fguillot/picoFeed",
                    "type": "git",
                    "reference": "origin/master"
                }
            }
        }
    ],
    "require": {
        "fguillot/picoFeed": "dev-master"
    }
}
Reiner answered 1/6, 2013 at 14:50 Comment(1)
Is it possible to change the installer path for such a "package"?Respirator
R
0

As an addition to the answer from @George, regarding the comment from @DavidOliver, here's how you should be able to change the package install target:

"repositories" : [
    {
        "type"    : "package",
        "package" : {
            "name"    : "vend0r/p4ckage",
            "version" : "dev-master",
            "type"    : "foo-library",
            "dist"    : {
                "url"  : "https://github.com/vend0r/p4ckage.git",
                "type" : "vend0r/p4ckage"
            },
            "source"  : {
                "url"       : "https://github.com/vend0r/p4ckage.git",
                "type"      : "git",
                "reference" : "origin/master"
            }
        }
    }
]
...
"extra" : {
    "installer-paths" : {
        "libraries/footype" : [
            "type:foo-library"
        ],
    }
}
...
"require" : {
    "vend0r/p4ckage" : "dev-master"
}
Ron answered 21/12, 2015 at 13:40 Comment(1)
I stumbled upon this looking how to install a non-composer repository to a custom path; it turns out that it cannot be done by only requiring composer/installers: https://mcmap.net/q/409497/-composer-is-ignoring-installer-paths-configuration . There's also a solution with oomphinc/composer-installers-extender on the same page.Electrocardiogram

© 2022 - 2024 — McMap. All rights reserved.