我已经使用composer安装了这个库: mailchimp
到我的codeigniter 2.x项目。我从控制器调用库:
$MailChimp = new \MailChimp('abc123abc123abc123abc123abc123-us1');
但错误是:
Class 'MailChimp' not found in /var/www/CI/application/controllers/auth.php
其中auth是我调用MailChimp类的控制器。
答案 0 :(得分:2)
看起来您只需要将类切换为其全名:
$MailChimp = new \DrewM\MailChimp\MailChimp('abc123abc123abc123abc123abc123-us1');
或者,use
命名空间在初始化MailChimp对象之前wrapper's documentation建议:
use \DrewM\MailChimp\MailChimp;
$MailChimp = new MailChimp('abc123abc123abc123abc123abc123-us1');