A Laravel package for interacting with the Listmonk API.
-
Install the package via Composer:
composer require theafolayan/listmonk-laravel
-
Publish the configuration file:
php artisan vendor:publish --tag=listmonk-config
-
Configure your
.env
file with the following variables:LISTMONK_BASE_URL= LISTMONK_API_USERE= LISTMONK_API_TOKEN=
Get all subscribers:
use Theafolayan\ListmonkLaravel\Facades\Listmonk;
$subscribers = Listmonk::getSubscribers();
$newSubscriber = Listmonk::createSubscriber([
'email' => 'john.doe@example.com',
'name' => 'John Doe',
'status' => 'enabled',
]);
Get all lists:
$lists = Listmonk::getLists();
$newList = Listmonk::createList([
'name' => 'Weekly Newsletter',
'description' => 'Updates and news every week.',
]);
You can use the Listmonk
facade to interact with the Listmonk API:
use Theafolayan\ListmonkLaravel\Facades\Listmonk;
$subscribers = Listmonk::getSubscribers();
$list = Listmonk::createList(['name' => 'New List']);
Alternatively, you can inject the Listmonk class into your services:
use Theafolayan\ListmonkLaravel\Listmonk;
class YourService
{
protected $listmonk;
public function __construct(Listmonk $listmonk)
{
$this->listmonk = $listmonk;
}
public function getSubscribers()
{
return $this->listmonk->getSubscribers();
}
}
getSubscribers(array $filters = [])
createSubscriber(array $data)
getLists()
createList(array $data)
Contributions are welcome! To contribute:
- Fork the repository.
- Create a feature branch.
- Submit a pull request.
This package is open-sourced software licensed under the MIT license.