[英]Autoload Vendor with CakePHP v3.x and Composer
I'm trying to load this into my CakePHP 3.x app. 我试图加载该到我的CakePHP 3.X应用程序。 I'm totally clueless as to how I might do this with composer.
对于如何使用作曲家,我一无所知。 I've included other files with composer already but this wrapper doesn't seem to support it.
我已经在composer中包含了其他文件,但是该包装器似乎不支持它。
So, how do I either: 因此,我该怎么做:
It's all obviously changed since 2.x :( 自2.x以来,一切都明显改变了:(
Any pointers please? 有指针吗?
The answer was under my nose, on the cake docs . 答案在蛋糕文件上,在我的鼻子底下。
Manually required the wrapper: 手动要求包装器:
define('VENDOR', ROOT . DS . 'vendor' . DS);
require(VENDOR . 'thoughtco' . DS . 'freeagent' . DS . 'Freeagent.php');
Then modded the wrapper to use namespace: 然后修改包装器以使用名称空间:
namespace Freeagent;
Then instantiated it in my component. 然后在我的组件中实例化它。
use Freeagent\Freeagent;
...
public function __construct()
{
$this->client = new Freeagent('id', 'key');
}
Job done - maybe someone else might find it useful :) 工作完成-也许其他人可能会觉得有用:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.