Composer install wp-plugin to vendor dir

时间:2016-08-31 16:52:53

标签: wordpress composer-php

I'm using Roots/Bedrock for my WordPress structure and I want to use WebDevStudios/CMB2 as a library and not as a plugin.

The Roots/Bedrock composer.json specifies that dependencies of type:wordpress-plugin be installed in app/plugins. The WebDevStudios/CMB2 composer.json declares that it is a wordpress-plugin type, so it gets installed into app/plugins which is not where I want it.

How can I get this dependency to be installed into vendor and not app/plugins?

I have a suspicion I might have to fork CMB2 and change it's type from wordpress-plugin to library, but I'm hoping there is a cleaner solution.

1 个答案:

答案 0 :(得分:0)

我没有使用Roots / Bedrock但是在添加CMB2作为插件的依赖时(而不是将其作为单独的插件加载)我遇到了类似的问题。它正在wp-content/plugins而不是vendor安装插件。以下对我有用。

{
    "require": {
        "webdevstudios/cmb2": "^2.2",
    },
    "autoload"    : {
        "files": [
            "vendor/webdevstudios/cmb2/init.php"
        ]
    },
    "extra": {
        "installer-paths": {
            "vendor/webdevstudios/cmb2": ["webdevstudios/cmb2"]
        }
    }
}

关键是installer-paths条目告诉Composer我们要安装webdevstudios/cmb2的位置。

我在https://salferrarello.com/cmb2-composer-dependency/

撰写了一篇关于此事的博客文章