F481
F481

Reputation: 990

Symfony2 composer adding own bundle requirement

How can I install a specific Bundle (for example SonataGoutteBundle) to my Symfony2 project via composer?

I tried this, but it doesn't work for me. Any ideas what's wrong?

"repositories": [
    {
        "type": "package",
        "package": {
            "name": "sonata-project/sonatagouttebundle",
            "version": "dev-master",
            "dist": {
                "url": "https://github.com/sonata-project/SonataGoutteBundle.git",
                "type": "git"
            }
        }
    }
],
"require": {
     "php": ">=5.3.3",
     [...],
     "sonata-project/sonatagouttebundle": "dev-master"
}

Upvotes: 2

Views: 2753

Answers (2)

Jakub Zalas
Jakub Zalas

Reputation: 36191

You should provide a link to an archive (like zip) in "dist" section. If you want to use git you should define "source" section instead:

{
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "sonata-project/sonatagouttebundle",
                "version": "dev-master",
                "source": {
                    "url": "https://github.com/sonata-project/SonataGoutteBundle.git",
                    "type": "git",
                    "reference": "master"
                }
            }
        }
    ],
    "require": {
        "php": ">=5.3.3",
        "sonata-project/sonatagouttebundle": "dev-master"
    }
}

More about defining custom repositories: http://getcomposer.org/doc/04-schema.md#repositories

Upvotes: 3

Federkun
Federkun

Reputation: 36944

Try something like

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/sonata-project/SonataGoutteBundle.git"
        }
    ],

    "require": {
        "php": ">=5.3.3",
        "vendor/bundle": "dev-master"
    }
}

The SonataGoutteBundle must have a composer.json

In this particular case, this would work:

"repositories": [
    {
        "type": "package",
        "package": {
            "name": "sonata-project/goutte",
            "version": "dev-master",
            "source": {
                    "url": "https://github.com/sonata-project/SonataGoutteBundle.git",
                    "type": "git",
                    "reference": "master"
                }
        }
    }
],
"require": {
     "php": ">=5.3.3",
     "sonata-project/goutte": "dev-master"
}

For all options see the documentation

Upvotes: 4

Related Questions