使用不被识别没有找到“MailChimp”类

i am using this mailchimp-api according to the documentation i should just place

use \DrewM\MailChimp\MailChimp;

$MailChimp = new MailChimp('abc123abc123abc123abc123abc123-us1');

directory structure

  • index.php (this is where i call any library i use using use)

  • composer.json

  • vendor (this is the folder that contains all libraries from git and the autoload file)

    -- drewm

    --- mailchimp-api

    ---- src (this folder contains the Mailchimp.php that has namespace DrewM\MailChimp;)

  • configs (config directory)

    -- functions.php (this file contains the function for mailchimp)

now whenever i call this mailchimp() function i get

Fatal error: Uncaught Error: Class 'DrewM\MailChimp\MailChimp' not found

composer.json file

{
    "require": {
        "drewm/mailchimp-api": "^2.4",
        "ircmaxell/random-lib": "^1.2",
        "phpmailer/phpmailer": "^5.2"
    }
}

index.php

require_once './vendor/autoload.php';
require_once './config/functions.php';

functions.php

use \DrewM\MailChimp\MailChimp;
function mailchimp(){
    $MailChimp = new MailChimp('abc123abc123abc123abc123abc123-us1');
    $result = $MailChimp->get('lists');
    print_r($result);
}
查看全部
dstbp22002
dstbp22002
2017/08/16 12:21
  • php
  • namespaces
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

2个回复