knackline/laravel-listmonk
最新稳定版本:1.1
Composer 安装命令:
composer require knackline/laravel-listmonk
包简介
Laravel package for Listmonk API integration
README 文档
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.
统计信息
- 总下载量: 18
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-01