【问题标题】:composer is ignoring installer-paths configuration作曲家正在忽略安装程序路径配置
【发布时间】:2013-12-22 19:14:09
【问题描述】:

我第一次尝试在 composer 中使用 CakePHP,但我遇到了一些问题。

我有这个composer.json

{
  "name": "example.com.br",
  "repositories": [
    {
      "type": "pear",
      "url": "http://pear.cakephp.org"
    }
  ],
  "config": {
    "vendor-dir": "Vendor/"
  },
  "require": {
    "php": ">=5.4",
    "pear-cakephp/cakephp": ">=2.4.3",
    "cakephp/debug_kit": "2.2.*",
    "smottt/wideimage": "dev-master"
  },
  "extra": {
    "installer-paths": {
      "app/Plugin/DebugKit": ["cakephp/debug_kit"],
      "app/Vendor/Wideimage": ["smottt/wideimage"]
    }
  }  
}

当我运行composer install (or update) --prefer-dist 时,除了smottt/wideimage 之外,一切正常。

这个包被安装在/Vendor文件夹而不是/app/Vendor,所以,installer-paths被忽略了。

【问题讨论】:

    标签: php cakephp composer-php


    【解决方案1】:

    将您的自定义类型添加到installer-types

    {
      "installer-types": ["library", "myttype-1", "mytype-2"]
    }
    

    https://packagist.org/packages/oomphinc/composer-installers-extender

    【讨论】:

      【解决方案2】:

      当然,Danack has said 是真的:composer-installers 插件只支持包类型的选择列表。

      作为回应,我为 composer-installers 插件编写了an extension,它允许"installer-paths" 指令处理任意包类型。

      在您的 composer.json 中只需要 oomphinc/composer-installers-extender 并添加对任何其他任意包类型的支持:

      "extra": {
        "installer-types": ["library"],
        "installer-paths": {
          "special/package/": ["my/package"],
          "path/to/libraries/{$name}/": ["type:library"]
        }
      }
      

      对于没有指定类型的包,使用默认类型library

      【讨论】:

      • 干得好,但是如果我放库,所有类型库的包都在指定的文件夹中,我希望一个包在特定的文件夹中。
      • 我也有库类型将所有供应商移动到特定文件夹并且自定义类型被忽略的问题。
      【解决方案3】:

      使用作曲家的选项“脚本”(仅适用于 linux):

      "scripts": {
              "post-install-cmd": [
                  "php -r \"system('mv '.getcwd().'/Vendor/smottt/wideimage '.getcwd().'/Vendor/Wideimage');\""
              ]
          }
      

      【讨论】:

      • 这绝不是优雅的,但对于我来说,这是将其安装到正确目录的唯一方法。
      【解决方案4】:

      来自documentation

      您不能使用它来更改任何包的路径。这只是 适用于需要 composer/installers 并使用 它处理的自定义类型。

      来自您正在安装的packages 之一:

      {
          "name": "smottt/wideimage",
          "description": "An open-source PHP library for image manipulation. (With namespaces, PHP 5.3+)",
          "homepage": "http://wideimage.sourceforge.net",
          "type": "library",
          "license": ["GPL-2.0","LGPL-2.1"],
          "version": "11.02.19",
          "autoload": {
              "psr-0" : {
                "WideImage" : "lib/"
              }
          }
      }
      

      所以基本上你尝试安装的包不支持自定义安装路径。

      【讨论】:

        猜你喜欢
        • 2017-10-17
        • 2018-01-22
        • 2013-12-03
        • 2023-04-06
        • 1970-01-01
        • 2015-06-14
        • 1970-01-01
        • 2016-08-11
        • 1970-01-01
        相关资源
        最近更新 更多