2

如何通过 composer将特定的 Bundle(例如 SonataGoutteBundle)安装到我的 Symfony2 项目中?

我试过这个,但它对我不起作用。有什么想法有什么问题吗?

"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"
}
4

2 回答 2

4

尝试类似的东西

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

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

SonataGoutteBundle必须有 composer.json

在这种特殊情况下,这将起作用:

"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"
}

有关所有选项,请参阅文档

于 2012-07-14T19:27:06.260 回答
3

您应该在“dist”部分提供指向存档(如 zip)的链接。如果你想使用 git,你应该定义“源”部分:

{
    "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"
    }
}

有关定义自定义存储库的更多信息:http: //getcomposer.org/doc/04-schema.md#repositories

于 2012-07-14T19:43:18.767 回答