Question

I have a git repo that contains a few small and related libraries. Since the platform I am working with lacks proper dependency management, dealing with many git repos is a hassle, hence my team decided to put these into one git repo. I'm now working on having our software being installable via Composer. It is however not clear to me how to register each component in this git repo, as I'm not even sure it is possible to have more then one composer.json file per repo. Is this possible? And if so, how?

Était-ce utile?

La solution

"is it possible to have more then one composer.json file per repo."

No.

You can't register the components separately, they will be registered as one big dependency and you will have to import them all into other projects, rather than being able to pull them individually.

However you can register where each component lives in the directory structure so that the autoloader is able to load them correctly.

"autoload": {
    "psr-0": {
        "Intahwebz\\Component1": "src/Component1",
        "Intahwebz\\Component2": "src/Intahwebz/Component2",
        "Intahwebz": "src/"
    }
}

After including the Composer generated autoloader, creating a new class of type Intahwebz\Component1\TestClass will find it in the correct directory.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top