Composer安装包依赖项

时间:2017-02-10 01:22:09

标签: php nested package composer-php

我创建了一个在GIT仓库中设置的自定义包。 Composer成功地将文件拖到供应商目录中的一个目录中,但是我需要引入嵌套的依赖项,我找不到如何让它满意的答案。

这是主网站提取包的Composer文件:

{
    "name": "development/project",
    "type" : "project",
    "repositories": [
        {
            "type":"composer",
            "url":"https://wpackagist.org"
        },
       {
           "type": "package",
           "package": {
               "name": "development/package",
               "version": "0.0.1",
               "source": {
                   "type": "git",
                   "url": "https://developer@bitbucket.org/development/package.git",
                   "reference" : "v0.0.1"
               }
           }
        },
     ],

     "require": {
         "php": ">=5.4",
         "composer/installers": "~1.0",
     },

     "require-dev": {
         "development/package": "~0.0"
    }
}

这是包本身的本地Composer文件:

{
  "name": "development/package",
  "type" : "project",

  "require": {
    "php": ">=5.4",
    "composer/installers": "~1.0"
  },

  "require": {
    "ellislab/codeigniter": "~3.0"
  },
}

所以我想要发生的是,当我在主站点上运行Composer时,它会引入'开发/包'(它正在进行),但也会引入包依赖项'ellislab / codeigniter' 。感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

你的本地包中有无效的composer json,它应该是这样的(没有双require节点):

{
  "name": "development/package",
  "type" : "project",

  "require": {
    "php": ">=5.4",
    "composer/installers": "~1.0",
    "ellislab/codeigniter": "~3.0"
  }
}

Composer会自动提取根包的require节点和每个依赖包的require节点中定义的所有包,包括ellislab/codeigniter中的development/package