Download the PHP package betacie/mailchimp-bundle without Composer
On this page you can find all versions of the php package betacie/mailchimp-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package mailchimp-bundle
mailchimp-bundle
This bundle will help you synchronise your project's newsletter subscribers into MailChimp.
You can synchronize all your subscribers at once with a Symfony command : new users will be added to MailChimp, existing users will be updated and user no longer in your project will be deleted from MailChimp.
You can also synchronize subscribe / unsubscribe one at a time with events.
Optionnaly, it also help you to synchronize your list merge tags.
- Setup
- Configuration
- Usage
- Synchronize merge tags
- Full synchronization with command
- Unit synchronization with events
Setup
Add bundle to your project:
Add Betacie\MailChimpBundle\BetacieMailChimpBundle
to your AppKernel.php
:
Configuration
You need to add the list in MailChimp's backend first.
For each list you must define a configuration in your config.yml
:
Where listX
is the name of your MailChimp lists, and yourapp.providerX
is the key of your provider's service that will provide the subscribers that need to be synchronized in MailChimp. The key mc_language
is optional and will set this language for all subscribers in this list, see the list of accepted language codes.
Defining lists and providers is necessary only if you use full synchronization with the command.
Usage
Synchronize merge tags
Merge tags (or merge vars) are values you can add to your subscribers (for example the firstsname or birthdate of your user). You can then use these tags in your newsletters or create segments out of them.
To learn more about merge tags, please see this guide on MailChimp.
To synchronize you need to create your lists in MailChimp backend first. Then you need to add them in your config.yml
as shown in the MailChimp API.
You can then synchronize the tags using the app/console betacie:mailchimp:synchronize-merge-tags
command. Note that every tag that are present in MailChimp but are not defined in your configuration will be deleted along with associated values.
Full synchronization with command
You can synchronize all subscribers of your project at once by calling the Symfony command app/console betacie:mailchimp:synchronize-subscribers
. It will first fetch all the subscribers already present in MailChimp and unsubscribe any subscribers that are not in your projet (they might have been deleted on the project side), it will then send all your subscribers to MailChimp, new subscribers will be added and existing subscribers will be updated.
After configuring your lists in config.yml
, you need to create at least one Provider
that will be used by the Symfony command. Your provider should be accessible via a service key (the same you reference in subscriber_providers
in the configuration above):
It should implement Betacie\MailChimpBundle\Provider\ProviderInterface
and return an array of Betacie\MailChimpBundle\Subscriber\Subscriber
objects. The first argument of the Subscriber
object is its e-mail, the second argument is an array of merge tags values you need to add in MailChimp's backend in your list settings under List fields and *|MERGE|* tags
(see this guide on MailChimp to add merge tags in your list).
Unit synchronization with events
If you want realtime synchronization, you can dispatch custom events on your controllers (or anywhere). The subscribe event can be used both for adding a new subscriber or updating an existing one.
Here is an example of a subscribe event dispatch:
If you want to tell MailChimp that an existing subscriber has changed its e-mail, you can do it by adding the new-email
option to the merge tags:
Unsubscribe is simpler, you only need the email, all merge tags will be ignored:
All versions of mailchimp-bundle with dependencies
phpspec/phpspec Version ~2@dev
psr/log Version ^1.0
symfony/options-resolver Version ~2@dev