Back to Blog
Dotkernel API

How to implement MailChimp in Dotkernel API

Frequently Asked Questions

Which library does this tutorial use to add MailChimp to Dotkernel API? +

The tutorial uses drewm/mailchimp-api, installed with the command composer require drewm/mailchimp-api.

Where do you place the MailChimp configuration file? +

In config/autoload/mailchimp.global.php, a new configuration file created as part of Step 2.

What does the MailChimpFactory class do? +

It's a factory, created at src/App/src/MailChimp/Factory/MailChimpFactory.php, that reads the config from the container and returns an instance of DrewM\MailChimp\MailChimp.

Where do you register the MailChimp factory so the application can use it? +

In src/App/src/ConfigProvider.php, inside the getDependencies() method's factories array, by mapping MailChimp::class to MailChimpFactory::class, plus adding the corresponding use statements for MailChimp and MailChimpFactory.

How do you use MailChimp once it's wired up? +

By injecting MailChimp::class wherever it's needed, using @Inject.