knackline / laravel-listmonk
Laravel package for Listmonk API integration
1.1
2025-09-11 20:44 UTC
Requires
- php: ^8.0
- guzzlehttp/guzzle: ^7.0
- illuminate/http: ^9.0|^10.0|^11.0|^12.0
- illuminate/support: ^9.0|^10.0|^11.0|^12.0
- illuminate/validation: ^9.0|^10.0|^11.0|^12.0
Requires (Dev)
- mockery/mockery: ^1.4
- orchestra/testbench: ^7.0
- phpunit/phpunit: ^9.0
README
A Laravel package to interact with the Listmonk API, providing a fluent interface to manage subscribers, lists, campaigns, and more.
Features
- 🚀 Full API coverage for Listmonk
- 🔄 Fluent, object-oriented API
- 🛠 Built with Laravel best practices
- 📦 Easy installation and configuration
- 🔍 Comprehensive test suite
- 📝 Well-documented methods
Requirements
- PHP 8.0 or higher
- Laravel 9.x or higher
- Listmonk 2.0 or higher
Installation
You can install the package via Composer:
composer require knackline/laravel-listmonk
Publish the config file with:
php artisan vendor:publish --provider="Knackline\Listmonk\Providers\ListmonkServiceProvider" --tag="listmonk-config"
Configuration
Update your .env
file with your Listmonk credentials:
LISTMONK_URL=https://your-listmonk-installation.com LISTMONK_USERNAME=your-username LISTMONK_PASSWORD=your-password
Or modify the config/listmonk.php
file directly.
Usage
Facade
use Knackline\Listmonk\Facades\Listmonk; // Get all subscribers $subscribers = Listmonk::getSubscribers(); // Create a new subscriber $subscriber = Listmonk::createSubscriber([ 'email' => 'user@example.com', 'name' => 'John Doe', 'status' => 'enabled', 'lists' => [1, 2], // List IDs to subscribe to ]);
Dependency Injection
use Knackline\Listmonk\ListmonkClient; class YourController { protected $listmonk; public function __construct(ListmonkClient $listmonk) { $this->listmonk = $listmonk; } public function index() { $subscribers = $this->listmonk->getSubscribers(); // ... } }
Available Methods
Subscribers
getSubscribers(array $filters = [])
- Get all subscribersgetSubscriber(int $id)
- Get a subscriber by IDcreateSubscriber(array $data)
- Create a new subscriberupdateSubscriber(int $id, array $data)
- Update a subscriberdeleteSubscriber(int $id)
- Delete a subscriberblocklistSubscriber(int $id)
- Blocklist a subscriber
Lists
getLists(array $filters = [])
- Get all listsgetList(int $id)
- Get a list by IDcreateList(array $data)
- Create a new listupdateList(int $id, array $data)
- Update a listdeleteList(int $id)
- Delete a list
Campaigns
getCampaigns(array $filters = [])
- Get all campaignsgetCampaign(int $id)
- Get a campaign by IDcreateCampaign(array $data)
- Create a new campaignupdateCampaign(int $id, array $data)
- Update a campaigndeleteCampaign(int $id)
- Delete a campaignsendCampaign(int $campaignId, bool $sendNow = false)
- Send a campaign
Templates
getTemplates()
- Get all templatesgetTemplate(int $id)
- Get a template by IDcreateTemplate(array $data)
- Create a new templateupdateTemplate(int $id, array $data)
- Update a templatedeleteTemplate(int $id)
- Delete a template
Transactional Emails
sendTransactionalEmail(string $to, string $subject, string $body, array $data = [])
- Send a transactional email
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.