primd/listmonk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

primd/listmonk

最新稳定版本:1.0-beta

Composer 安装命令:

composer require primd/listmonk

包简介

Package aims to ease up the API calls to a listmonk API from PHP based application

README 文档

README

The package allows easy access to ListMonk API from PHP based applications.

Installation

You can install this library to your project via composer using the following command:

composer require adnanhussainturki/listmonk-php

Usage

<?php

require __DIR__ . 'vendor/autoload.php';

// Create a new ListMonk instance
$listMonk = new \ListMonk\ListMonk(
    "http://localhost:9000", // Server URL
    "listmonk", // Username
    "listmonk", // Password
);

?>

Managing lists

    
// Get all lists
$lists = $listMonk->lists()->getAll();
echo "All lists:\n";
foreach ($lists as $list) {
    echo $list->getId() . " - " . $list->getName() . "\n";
}

// Get a list by id
$list = $listMonk->lists()->get(3);
echo "List with id 3:\n";
echo $list->getId() . " - " . $list->getName() . "\n";

// Create a new list
$newList = new \ListMonk\Models\MonkList();
$newList->setName("Test List");
$newList->setType("private");
$newList->setOptin("single");
$newList->setTags(["test", "list"]);
$newListMonk = $listMonk->lists()->create($newList);
echo "New list created:\n";
echo $newListMonk->getId(). " - " . $newListMonk->getName() . "\n";


// Update the created list
$newListMonk->setName("Test List Updated");
$newListMonk->setType("public");
$newListMonk->setOptin("double");
$newListMonk->setTags(["test", "list", "updated"]);
$updatedList = $listMonk->lists()->update($newListMonk);
echo "Updated list:\n";
echo $updatedList->getId(). " - " . $updatedList->getName() . "\n";


// Delete the created list
$deletedList = $listMonk->lists()->delete($updatedList->getId());
echo "List deleted:\n";
echo $deletedList->getId(). " - " . $deletedList->getName() . "\n";

Managing subscribers

<?php

require_once __DIR__ . '/init.php';

// Get all subscribers
$subscribers = $listMonk->subscribers()->getAll();
echo "All subscribers:\n";
foreach ($subscribers as $subscriber) {
    echo $subscriber->getId() . " - " . $subscriber->getName() . "\n";
}

// Get a subscriber by id
$subscriber = $listMonk->subscribers()->get(5);
echo "Subscriber with id 1:\n";
echo $subscriber->getId() . " - " . $subscriber->getName() . "\n";

// Create a new subscriber
$newSubscriber = new \ListMonk\Models\MonkSubscriber();
$newSubscriber->setName("Test Subscriber");
$newSubscriber->setEmail(random_int(23, 1000). "@gmail.com");
$newSubscriber->setStatus("enabled");
$newSubscriber->setLists([1, 2]);

$newSubscriberMonk = $listMonk->subscribers()->create($newSubscriber);
echo "New subscriber created:\n";
echo $newSubscriberMonk->getId(). " - " . $newSubscriberMonk->getName() . "\n";

// Update the created subscriber
$newSubscriberMonk->setName("Test Subscriber Updated");
$newSubscriberMonk->setEmail(random_int(23, 1000). "@email.com");
$newSubscriberMonk->setStatus("disabled");
$newSubscriberMonk->setLists([1, 2, 3]);
$updatedSubscriber = $listMonk->subscribers()->update($newSubscriberMonk);
echo "Updated subscriber:\n";
echo $updatedSubscriber->getId(). " - " . $updatedSubscriber->getName() . "\n";

// Delete the created subscriber
$deletedSubscriber = $listMonk->subscribers()->delete($updatedSubscriber->getId());
echo "Subscriber deleted:\n";
echo $deletedSubscriber->getId(). " - " . $deletedSubscriber->getName() . "\n";
 

Whats more to be done?

  • All routes of Subscriber is not yet handled.
  • Campaign needs to be implemented.
  • Media needs to be implemented.
  • Import needs to be implemented.
  • Template needs to be implemented.
  • Transactional needs to be implemented.

Buy me a coffee

How to contribute

  • Create a fork, make changes and send a pull request.
  • Raise a issue

License

Licensed under Apache 2.0. You can check its details here.

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-27