composer正在忽略安装程序路径配置


composer is ignoring installer-paths configuration

我第一次尝试在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文件夹中,因此,安装程序路径被忽略。

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

作为回应,我为composer-installers插件编写了一个扩展,它允许"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

来自文档。

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

从您正在安装的软件包之一:

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

因此,基本上,您尝试安装的软件包不支持自定义安装路径。

使用composer的选项"script"(仅适用于linux):

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

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

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

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