【问题标题】:composer to install a package or module in a custom path?作曲家在自定义路径中安装包或模块?
【发布时间】:2019-09-08 13:04:39
【问题描述】:

我尝试在特定路径中安装带有 composer 的 Drupal 模块,

我检查了这些链接,但我无法弄清楚。

请检查一下,告诉我哪里出了问题,我应该怎么做?

我想要什么?

modules/patched 目录中安装签名字段模块。

这是我的composer.json 文件的一部分,与此问题相关。

"require": {
    "composer/installers": "^1.0.24",
    "drupal/signature_field": "^1.0@RC",
},

    "installer-paths": {
        "core": ["type:drupal-core"],
        "modules/contrib/{$name}": ["type:drupal-module"],
        "profiles/contrib/{$name}": ["type:drupal-profile"],
        "themes/contrib/{$name}": ["type:drupal-theme"],
        "drush/contrib/{$name}": ["type:drupal-drush"],
        "modules/custom/{$name}": ["type:drupal-custom-module"],
        "themes/custom/{$name}": ["type:drupal-custom-theme"],
        "modules/patched/{$name}": ["type:drupal-patched-module"]
    },
    "patches": {
        "drupal/signature_field": {
            "Drupal Signature Field fix multi feilds": "modules/patched/signature_field/signature_field-2993223-08.patch"     
        }
    }
},

最后我做了composer installcomposer update,但是模块没有转移到我想要的文件夹

【问题讨论】:

    标签: php module drupal-8


    【解决方案1】:

    也许这会有所帮助(请注意extra):

    {
        "extra": {
            "installer-paths": {
                "modules/patched/{$name}": ["drupal/signature_field"],
                "modules/patched/{$name}": ["another/package"]
            }
        }
    }
    

    Reference, GitHub comment

    这可能会起作用:

    {
        "extra": {
            "installer-paths": {
                "modules/patched/{$name}": ["drupal/signature_field"]
            }
        },
        "extra": {
            "installer-paths": {
                "modules/patched/{$name}": ["drupal/another_module"]
            }
        }
    }
    

    {
        "extra": {
            "installer-paths": {
                "modules/patched/{$name}": ["drupal/signature_field"]
            },
            "installer-paths": {
                "modules/patched/{$name}": ["drupal/another_module"]
            }
        }
    }
    

    还有,

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

    您也可以通过typegroup您的包裹:

    {
        "extra": {
            "installer-paths": {
                "your/custom/path/{$name}/": ["type:wordpress-plugin"]
            }
        }
    }
    

    或某些vendor

    {
        "extra": {
            "installer-paths": {
                "your/custom/path/{$name}/": ["vendor:drupal"]
            }
        }
    }
    

    【讨论】:

    • 它可以,但是当我有几个模块与这种情况下,我应该如何添加?
    • 你的意思是,你想在同一个路径中添加多个模块?
    • 在这种情况下,只有第一个将被作曲家应用,接下来的任何其他都将被忽略,在这种情况下只是签名字段
    • 您是否尝试为需要在特定目录中安装的每个软件包创建单独的extra 字段?
    • 我为每个包额外添加一个是错误的,也许有 100 个包应该添加至少 200 行额外的代码。
    【解决方案2】:

    在那里我们应该定义自定义路径并定义应该在该路径中安装哪个模块或包。

    喜欢这个

    "installer-paths": {
    
        // custom path with the list of items that should installed there.
    
        "modules/patched/{$name}": [
            "drupal/signature_field",
            "drupal/eck",
            "drupal/auto_entitylabel"
        ],
    }
    

    包或模块也应该在您的要求部分中。

    "require": {
            "composer/installers": "^1.0.24",
            "drupal/auto_entitylabel": "2.x-dev",
            "drupal/signature_field": "^1.0@RC",
            "drupal/eck": "^1.0@alpha",
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-22
      • 1970-01-01
      • 2017-11-04
      • 2017-10-17
      • 2018-06-19
      • 2014-02-26
      • 2015-10-18
      • 2012-11-03
      相关资源
      最近更新 更多