beelab/v3-mailchimp-api-php
Lightweight PHP wrapper for MailChimp API v3. Provides convenient functions on top of the REST endpoints using Guzzle, installable via Composer. Includes a PHPUnit test suite. Requires PHP 5.5+.
Pros:
subscriber.unsubscribe) can integrate with Laravel’s event system via custom listeners.Cons:
MailchimpManager facade or config publisher).config/cache system isn’t leveraged (e.g., no mailchimp.php config file).Illuminate\Support\Facades\Log or App\Exceptions\Handler would need custom integration.modules package).Http facade), reducing friction.MailchimpSubscriberUnsubscribed).AppServiceProvider binding).config/mailchimp.php).SendMailchimpCampaignJob).composer require beelab/v3-mailchimp-api-php
MailchimpService class.guzzlehttp/guzzle:^7.0 override).^8.0.^7.0.mailchimp.php config file:
// config/mailchimp.php
return [
'api_key' => env('MAILCHIMP_API_KEY'),
'server' => env('MAILCHIMP_SERVER', 'us12'),
];
// app/Providers/MailchimpServiceProvider.php
public function register()
{
$this->app->singleton('mailchimp', function ($app) {
$config = $app['config']['mailchimp'];
return new \BeeLab\MailchimpApi\Mailchimp($config['api_key'], $config['server']);
});
}
// app/Facades/Mailchimp.php
public static function lists() { return app('mailchimp')->lists(); }
Route::post('/mailchimp/webhook', [MailchimpWebhookController::class, 'handle'])).Throwable instead of Exception).composer.json:
"require": {
"guzzlehttp/guzzle": "^7.0",
"beelab/v3-mailchimp-api-php": "dev-main"
},
"replace": {
"guzzlehttp/guzzle": "guzzlehttp/guzzle:^7.0"
}
// app/Listeners/HandleMailchimpUnsubscribe.php
public function handle(MailchimpWebhookEvent $event)
{
if ($event->type === 'subscriber.unsubscribe') {
// Update local DB or trigger other events
}
}
logs/mailchimp.log.How can I help you explore Laravel packages today?