作曲家忽略zip依赖的composer.json文件 [英] Composer ignoring zip dependecies' composer.json file

查看:68
本文介绍了作曲家忽略zip依赖的composer.json文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Composer用于需要处理一些依赖性的项目,但是我遇到了一个非常奇怪的问题。 Composer忽略子程序包中包含的composer.json文件。

I'm using Composer for a project that needs to handle some dependencies but I got a really weird issue. Composer is ignoring the composer.json file contained in child packages.

我的项目需要检索一些自定义zip程序包,在这些程序包中composer.json文件定义了其他要求。这些要求的存储库在composer.json根文件中声明,因为Composer无法递归获取存储库。

My project needs to retrieve some custom zip packages, in these packages a composer.json file defines other requirements. The repositories of these requirements are declared in the root composer.json file since Composer cant recursively fetch repositories.

问题是在下载,解压缩并放置了我的zip包之后在供应商目录中,composer完全忽略了定义了其他要求的composer.json ...

The thing is that after my zip package is downloaded, unpacked and placed in the vendor dir, composer totally ignores its composer.json where other requirements are defined...

zip压缩文件如下:

The zip archive is something like this:


  • / dir1

  • / dir2

  • file1

  • file2

  • composer.json

  • /dir1
  • /dir2
  • file1
  • file2
  • composer.json

让您了解这是我的根composer.json如下:

To give you an idea this is how my root composer.json looks like:

{
    "name": "myproject/project",
    "type": "library",
    "repositories": [    
        {
        "packagist" : false 
        },
        {
             "type": "package", 
             "package": {
                 "name" : "giulianobundles/mybundle",
                 "version" : "1",
             "dist": {
                "url": "http://url/to/zip/file",
                     "type": "zip"
                 }
             }
        },
        {
            "type": "package", 
            "package": {
                "name" : "giulianobundles/mybundlerequirement",
                "version" : "1",
        "dist": {
                    "url": "http://url/to/zip/file",
                "type": "zip"
        },
        }
    },  
    ],
    "require": {
        "php": ">=5.3.2",
         "giulianobundles/mybundle": "*"             
    },
    "autoload": {
        "psr-0": {
            "config": "./"
        }
    },
}

和捆绑包的composer.json包看起来如

and the bundle's composer.json package looks like

{
    "name": "giulianobundles/mybundle",
    "type":"library",
    "require": {
        "giulianobundles/mybundlerequirement": "1"
    }
}

Mybundle软件包成功获得已安装,但其composer.json文件被完全忽略。任何的想法?我想念什么?

Mybundle package get succesfully installed but its composer.json file is totally ignored. Any idea? What am I missing?

推荐答案

实际上,Composer不会递归地查看文件系统中的composer.json文件 。它需要查看存储库中的composer.json文件。通常的工作方式是,程序包在某处具有git或svn URL。例如,Composer将从存储库中直接获取 git://< host> /< package> /composer.json ,以弄清该软件包的依赖关系,甚至

Indeed, Composer will not recursively look at composer.json files in the file system. It needs to see the composer.json files in the repository. The way it usually works is that a package has a git or svn URL somewhere. Composer will fetch, for instance, git://<host>/<package>/composer.json directly from the repository to figure out that package's dependencies before it's even installed to calculate the overall dependencies.

在您的情况下,您要在自己的作曲家中内联定义 package 。 json文件。 代替依赖项中的composer.json文件。这意味着Composer将 package:{...} 用作该软件包的规范composer.json文件,它不会查看代码本身。特别是在打开包装后。它将Zip文件视为自己没有composer.json文件。

In your case, you are defining a package inline in your own composer.json file. This is used instead of a composer.json file in the dependency. This means Composer takes the "package": { ... } to be the canonical composer.json file for that package, it will not look into the code itself; especially not after unpacking it. It treats the Zip file as if it had no composer.json file of its own.

package中定义依赖项:{。 ..} 或将代码托管在版本控制系统中,Composer可以从该版本控制系统中获取composer.json文件。

Define the dependencies in the "package": { ... } or host the code in a version control system from which Composer can fetch the composer.json file.

这篇关于作曲家忽略zip依赖的composer.json文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆