且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么使用PSR4自动加载功能不会在classmap/namespaces文件中添加任何类?

更新时间:2023-11-17 09:12:04

根据 @stof 在GitHub上发表的评论 Composer 不支持加载类型为 package 的存储库中的 composer.json 文件. package 类型的目标是下载支持 Composer 的项目.因此,从不读取文件 composer.json .

As per @stof comment at GitHub, Composer doesn't support loading of composer.json file from the repositories of the type package. The goal of a package type is to download projects which are not supporting Composer. Therefore composer.json file is never read.

解决方案是改用 vcs 类型.这是应该起作用的 composer.json :

Solution is to use vcs type instead. Here is the composer.json which should work:

{
  "require": {
    "queueit/knownuserv3": "dev-master"
  },
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/queueit/KnownUser.V3.PHP"
    }
  ]
}

否则,您将必须在软件包存储库中完全复制项目元数据,这很难维护."

Otherwise "you would have to copy the project metadata entirely in your package repository, and this is harder to maintain".