如何将Composer中的CakePHP插件安装到app / Plugin中

时间:2022-04-22 16:24:28

I'm trying to install this plugin: https://github.com/ichikaway/cakephp-mongodb/ into my CakePHP project using Composer. And everything was smooth, but it installed into [project root]/Plugin (directory created by Composer I guess) instead of [project root]/app/Plugin.

我正在尝试使用Composer将这个插件:https://github.com/ichikaway/cakephp-mongodb/安装到我的CakePHP项目中。一切顺利,但它安装到[project root] / Plugin(我猜测由Composer创建的目录)而不是[project root] / app / Plugin。

Obviously, in that case, it's impossible to load it by using:

显然,在这种情况下,使用以下方法加载它是不可能的:

<?php
//app/Config/bootstrap.php
CakePlugin::load('Mongodb');

If I manually move it to the second dir, it works just fine. But then I have two directories, which is terribly misleading. I know from my experience that one will eventually assume the plugin gets updated while in fact, in app/Plugin there's an older version of it, the one i had to manually copy there.

如果我手动将它移动到第二个目录,它就可以正常工作。但后来我有两个目录,这是非常误导。我从我的经验中知道,最终会假设插件得到更新,而实际上,在app / Plugin中有一个旧版本,我必须手动复制那里。

So my question is: How do I do install CakePHP plugins from Composer properly, so they go into app/Plugin?

所以我的问题是:如何正确安装Composer中的CakePHP插件,以便进入app / Plugin?

Thanks for the help!

谢谢您的帮助!

1 个解决方案

#1


Add the required plugin line to /app/composer.json instead of adding it to /composer.json.

将所需的插件行添加到/app/composer.json,而不是将其添加到/composer.json。

Minimum contents of app/composer.json:

app / composer.json的最小内容:

{
    "require": {
        "ichikaway/cakephp-mongodb": "2.2.*@dev"
    }
}

Then just run composer update from your console while in the app folder instead of from your project's root folder. This will install it to the Plugin directory relative to your current position on the server.

然后在app文件夹中而不是从项目的根文件夹中,从控制台运行composer update。这将相对于您在服务器上的当前位置将其安装到Plugin目录中。

#1


Add the required plugin line to /app/composer.json instead of adding it to /composer.json.

将所需的插件行添加到/app/composer.json,而不是将其添加到/composer.json。

Minimum contents of app/composer.json:

app / composer.json的最小内容:

{
    "require": {
        "ichikaway/cakephp-mongodb": "2.2.*@dev"
    }
}

Then just run composer update from your console while in the app folder instead of from your project's root folder. This will install it to the Plugin directory relative to your current position on the server.

然后在app文件夹中而不是从项目的根文件夹中,从控制台运行composer update。这将相对于您在服务器上的当前位置将其安装到Plugin目录中。