I have this 3rd party class Mailchimp.php which I need to include in my controller so that I can create an object and make api calls. But I'm not able to do so. I get this error when I try to run my controller.

Class 'Mailchimp' not found in /var/www/html/magentotwo/app/code/Vss/Mailchimp/Controller/Index/Add.php

I've installed mailchimp through composer through following command

composer require drewm/mailchimp-api

and can find the library in my magento's vendor folder.

Following is the code of my controller:


namespace Vss\Mailchimp\Controller\Index;

use Mailchimp;

class Add extends \Vss\Mailchimp\Controller\Index\Index

    public function execute()
        $api_key = $this->_scopeConfig->getValue('mailchimp/apikey/api_key_frontend', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
        $MailChimp = new Mailchimp($api_key);
        $result = $MailChimp->get('lists');

Following is the folder structure of library installed enter image description here

Please tell me how to proceed further.

1 Answer 1


According to documentation https://github.com/drewm/mailchimp-api you should use

use \DrewM\MailChimp\MailChimp;

And you can test following way

$MailChimp = new MailChimp('abc123abc123abc123abc123abc123-us1');
$result = $MailChimp->get('lists');

  • Yes. But it worked with use MailChimp\MailChimp; instead. Thanks.
    – MAK
    Nov 8, 2016 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.