如何在软件包而非项目上设置软件包的安装目录? [英] How to set the install directory for a package on the package, instead of on the project?

查看:136
本文介绍了如何在软件包而非项目上设置软件包的安装目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个自定义的作曲家程序包. composer软件包必须安装到自定义文件夹,而不是我希望将其安装在packages/中的vendors/目录.这就是我的composer.json的样子:

I am working on creating a custom composer package. The composer package must install to a custom folder instead of vendors/ directory I want it to be installed in packages/. This is how my composer.json looks like:

{
"name": "demo/contentfeed",
"description": "This is yet another Lumen composer package wrapper",
"type": "lumen-plugin",
"version": "1.1.5",
"keywords": ["demo","lumen","drupal"],
"homepage": "https://github.com/gauravmehrasrijan/lumen-feeds",
"require": {
    "composer/installers": "^1.0.24"
},
"autoload": {
    "psr-4": {
        "demo\\Contentfeed\\": "/src"
    }
},
"extra": {
    "installer-name": "packages",
    "installer-paths": {
        "packages": ["demo/contentfeed"]
    }
},
"license": "MIT",
"minimum-stability": "dev",
"authors": [
    {
        "name": "Gaurav Mehra",
        "email": "gauravmehra1987@gmail.com"
    }
]
}

在跳到这里之前,我还尝试了此链接但这对我不起作用,我额外添加了安装程序名称密钥,但没有成功.

Before jumping here I also tried the solution posted in this link but it didn't work for me, I added installer-name key in extra, but no success.

推荐答案

这是不可能的,文档

[...]软件包作者可以通过直接在其composer.json中设置路径或通过动态软件包类型来确定软件包安装位置的能力:"type":"framework-install -here".

[...] The ability for a package author to determine where a package will be installed either through setting the path directly in their composer.json or through a dynamic package type: "type": "framework-install-here".

已经提出了很多次.甚至早实施一次,然后删除. 安装程序不会执行此操作,因为这将允许单个程序包作者在未经用户同意的情况下清除整个文件夹.然后那个用户会来这里对我们大喊.

It has been proposed many times. Even implemented once early on and then removed. Installers won't do this because it would allow a single package author to wipe out entire folders without the user's consent. That user would then come here to yell at us.

(强调我的)

您正在使用的两个键(installer-pathsinstaller-name)的作用与您想象的不同:

The two keys you are using (installer-paths and installer-name) serve a different purpose than what you imagine:

  • installer-name:允许软件包作者(您)说您的软件包应安装在与vendor/name不同的目录下.对于您而言,它不是安装在vendor/demo/contentfeed上,而是安装在vendor/demo/packages下(因为您在composer.json中进行了设置)
  • installer-paths:允许软件包消费者设置某些软件包或软件包或软件包家族的自定义安装路径.对于软件包composer.json无效,此设置仅适用于项目配置.
  • installer-name: allows the package author (you) to say your package should be installed under a different directory than vendor/name. In your case, instead of being installed on vendor/demo/contentfeed, it would be installed under vendor/demo/packages (because of your setting in composer.json)
  • installer-paths: allows the package consumer to set a custom install path for a certain package or packages or package family. On a package composer.json has no effect, this setting is only for the project configuration.

这篇关于如何在软件包而非项目上设置软件包的安装目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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