简体   繁体   中英

Autoload Vendor with CakePHP v3.x and Composer

I'm trying to load this into my CakePHP 3.x app. 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.

So, how do I either:

  • Do this with Composer
  • Manually load the Vendor in 3.x

It's all obviously changed since 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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM