2017 © Pedro Peláez
 

library mailchimpv3-laravel

A minimal service provider to set up and use the Mailchimp Api v3 PHP library in Laravel 5.*

image

blenderdeluxe/mailchimpv3-laravel

A minimal service provider to set up and use the Mailchimp Api v3 PHP library in Laravel 5.*

  • Thursday, November 23, 2017
  • by blenderdeluxe
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

fraterblack/mailchimpv3-laravel

A minimal service provider to set up and use the Mailchimp APi v3 PHP library in Laravel v5.*, (*1)

This service provider use Mailchimp API https://github.com/drewm/mailchimp-api. A super-simple, minimum abstraction Mailchimp API v3 wrapper, in PHP., (*2)

Installation

You can install using Composer:, (*3)

composer require fraterblack/mailchimpv3-laravel

Register the service provider in config/app.php by inserting into the providers array, (*4)

'providers' => [
    Fraterblack\Mailchimp\MailchimpServiceProvider::class,
]

To publish the default configuration file, execute the following command:, (*5)

php artisan vendor:publish --provider="Fraterblack\Mailchimp\MailchimpServiceProvider"

Edit your .env file, (*6)

MAILCHIMP_API_KEY="your-api-key-here"

for more info check "http://kb.mailchimp.com/accounts/management/about-api-keys#Find-or-Generate-Your-API-Key", (*7)

How it works

This package contains a service provider, which binds an instance of an initialized Mailchimp API client to the IoC-container., (*8)

You recieve the Mailchimp API client through depencency injection already set up with your own API key., (*9)

Usage example, (*10)

class NewsletterManager
{
    protected $mailChimp;
    protected $listId = '1234567890';        // Id of newsletter list

    /**
     * Pull the Mailchimp API instance from the IoC-container.
     */
    public function __construct(\DrewM\MailChimp\MailChimp $mailChimp)
    {
        $this->mailChimp = $mailChimp;
    }

    /**
     * Add a subscriber in a list
     * for more info check "http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/"
     */
    public function addEmailToList($email)
    {
        try {
            $result = $this->mailChimp->post("lists/" . $this->listId . "/members", [
                'email_address' => $email,
                'status'        => 'subscribed',
            ]);
        } catch (\Exception $e) {
            // do something
        }
    }

    /**
     * Get lists
     * for more info check "http://developer.mailchimp.com/documentation/mailchimp/reference/lists/"
     */
    public function getLists()
    {
        try {
            $result = $this->mailChimp->get("lists");
        } catch (\Exception $e) {
            // do something
        }
    }
}

For more examples of usage:, (*11)

MailChimp API - https://github.com/drewm/mailchimp-api, (*12)

Mailchimp V3 Documentation - http://developer.mailchimp.com/documentation/mailchimp, (*13)

This package is based on:, (*14)

Based on https://github.com/skovmand/mailchimp-laravel, (*15)

The Versions

23/11 2017

dev-master

9999999-dev

A minimal service provider to set up and use the Mailchimp Api v3 PHP library in Laravel 5.*

  Sources   Download

MIT

The Requires

 

23/11 2017

1.0

1.0.0.0

A minimal service provider to set up and use the Mailchimp Api v3 PHP library in Laravel 5.*

  Sources   Download

MIT

The Requires