knackline/laravel-listmonk

Laravel package for Listmonk API integration

1.1 2025-09-11 20:44 UTC

This package is auto-updated.

Last update: 2025-09-11 20:48:51 UTC


README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

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 subscribers
  • getSubscriber(int $id) - Get a subscriber by ID
  • createSubscriber(array $data) - Create a new subscriber
  • updateSubscriber(int $id, array $data) - Update a subscriber
  • deleteSubscriber(int $id) - Delete a subscriber
  • blocklistSubscriber(int $id) - Blocklist a subscriber

Lists

  • getLists(array $filters = []) - Get all lists
  • getList(int $id) - Get a list by ID
  • createList(array $data) - Create a new list
  • updateList(int $id, array $data) - Update a list
  • deleteList(int $id) - Delete a list

Campaigns

  • getCampaigns(array $filters = []) - Get all campaigns
  • getCampaign(int $id) - Get a campaign by ID
  • createCampaign(array $data) - Create a new campaign
  • updateCampaign(int $id, array $data) - Update a campaign
  • deleteCampaign(int $id) - Delete a campaign
  • sendCampaign(int $campaignId, bool $sendNow = false) - Send a campaign

Templates

  • getTemplates() - Get all templates
  • getTemplate(int $id) - Get a template by ID
  • createTemplate(array $data) - Create a new template
  • updateTemplate(int $id, array $data) - Update a template
  • deleteTemplate(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.