Symfony2编写器添加自己的bundle要求

时间:2012-07-14 18:49:30

标签: symfony-2.1 composer-php

如何通过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"
}

2 个答案:

答案 0 :(得分: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"
}

对于所有选项,请参阅documentation

答案 1 :(得分:3)

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

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