How to use a local directory as a dependency?

2

I am designing a relatively large project in my company that is composed of several packages in PHP. Some of these packages are standard packages and others are bundles of Symfony applications.

When working with Composer, we usually point the name of a dependency to the branch or version being used - however, this dependency usually has to be in Github and listed in Packagist. (this is the normal flow, although there are alternatives)

In my case, I still do not want to have to commit any code, so the dependencies need to be local directories. I have already defined the composer.json of dependency file like this:

{
    "name": "rodrigorigotti/shared"
    "autoload": {
        "psr-0": {
            "RodrigoRigotti": "src/"
        }
    }
}

And the project that contains this dependency has composer.json like this:

{
    "name": "rodrigorigotti/app",
    "repositories": [
        {
            "type": "vcs",
            "url": "/var/www/rodrigorigotti/shared"
        }
    ],
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "~2.4",
        "rodrigorigotti/shared": "*"
    },
    "autoload": {
        "psr-0": { "": "src/" }
    },
}

(note: composer.json files are WELL simplified for the purpose of the question)

However, when I run the command composer install or composer update in the application that has the dependency, I have received this error:

[InvalidArgumentException]                                        
No driver found to handle VCS repository /var/www/rodrigorigotti/shared

Does anyone know how to solve it?

    
asked by anonymous 19.02.2014 / 13:48

1 answer

0

Dscobri. The directory to be used as a dependency must be a Git project ( git init ), even though it is not in any remote repository. Then just commit.

In addition, you should reference the correct branch or version in the composer.json of the project that will contain the other projects:

{
    "name": "rodrigorigotti/app",
    "repositories": [
        {
            "type": "vcs",
            "url": "/var/www/rodrigorigotti/shared"
        }
    ],
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "~2.4",
        "rodrigorigotti/shared": "dev-master"
    },
    "autoload": {
        "psr-0": { "": "src/" }
    },
}
    
19.02.2014 / 14:58