2
votes

I have a symfony project with some bundles.
I have a bundle which is not in github (proprietary in our own server). So, we have a functionnal git repository in our server.
This is a generical bundle, so we need to use it with composer.

I am looking for a way to add the repository in my composer.json (for each Symfony project)
I red this article http://marekkalnik.tumblr.com/post/22929686367/composer-installing-package-from-local-git-repository but it doesn't work...

"require": {
    ...
    "bt/commonbundle": "dev-master"

},
"repositories" : [{
    "type" : "vcs",
    "url" : "/absolute/path/to/my/repo/CommonBundle.git"
}],  

CommonBundle.git is a bare repo (i also tried with the working dir...)
I tried with vcs type and git type

The result is :

[Composer\Repository\InvalidRepositoryException]  
    No valid composer.json was found in any branch or tag of /absolute/path/to/my/repo/CommonBundle.git, could not load a package from it.  

I typed "composer validate" in my bundle and my json is valid

Do you have solution for this kind of problem ?
I would like :

  • Use composer (cmd: composer update)
  • to see my proprietary bundle in the vendor folder

Edit :
Thank to pozs, I forgot to commit my composer.json file....
But now, composer ask me to install symfony/icu, but I don't use this, so why ?
I can't install the php library

Thank you,
Best regards

2
Are you sure, your composer.json file is committed (and even pushed, if the repo is not a local copy)? - pozs
Yes, my composer.json file is in my bundle directory and in my bare repo. - Epharion
Well, your error specifically says, that the composer.json file cannot be found there (in any branch/tag) -- but it could found the git repo itself. Could you do a fresh clone from /absolute/path/to/my/repo/CommonBundle.git to see what's in there? - pozs
Arrghhh, I am so stupid. Indeed, I did'nt commit the composer file ....... But now, I have a message that ask me to install symfony/icu, I don't use this, so why ? - Epharion
One/some of your required packages may require it (but in that case composer would just install it, not demand it) ... maybe symfony.com/doc/current/components/intl.html ? - pozs

2 Answers

2
votes

You must writing another composer.json in your repository, for example:

{
    "name": "nameOfYourBundle",
    "type": "symfony-bundle",
    "description": "some description",
    "authors": [
        {
            "name": "author",
            "homepage": "http://homepage"
        }
    ],
    "require": {
    },
    "require-dev": {
    },
    "autoload": {
        "psr-4": { "path\\to\\your\\bundle": "" } // psr-4/psr-0 is for structure files
    }
}
0
votes

Take a look on this snipet

{
    "require": {
        "notihnio/foo": "master"
    },
    "repositories": [
        {
            "type": "vcs",
            "url":  "https://username:[email protected]/notihnio/foo"
        }
    ]
}

i have also created a post for this. https://notihnio.tumblr.com/post/142674566481/using-composer-with-private-packages