https://github.com/theafolayan/listmonk-laravel
A Laravel package for interacting with the Listmonk API.
https://github.com/theafolayan/listmonk-laravel
laravel listmonk listmonk-api
Last synced: 16 days ago
JSON representation
A Laravel package for interacting with the Listmonk API.
- Host: GitHub
- URL: https://github.com/theafolayan/listmonk-laravel
- Owner: theafolayan
- Created: 2025-01-05T19:05:18.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-02-04T18:38:07.000Z (4 months ago)
- Last Synced: 2025-05-09T01:49:15.884Z (16 days ago)
- Topics: laravel, listmonk, listmonk-api
- Language: PHP
- Homepage:
- Size: 252 KB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Listmonk Laravel
A Laravel package for interacting with the [Listmonk API](https://listmonk.app/docs/apis/apis/).
## Installation
1. Install the package via Composer:
```sh
composer require theafolayan/listmonk-laravel
```2. Publish the configuration file:
```sh
php artisan vendor:publish --tag=listmonk-config
```3. Configure your `.env` file with the following variables:
```env
LISTMONK_BASE_URL=
LISTMONK_API_USERE=
LISTMONK_API_TOKEN=
```## Usage
### Example: Manage Subscribers
Get all subscribers:
```php
use Theafolayan\ListmonkLaravel\Facades\Listmonk;
$subscribers = Listmonk::getSubscribers();
```
### Add a subscriber
```php
$newSubscriber = Listmonk::createSubscriber([
'email' => '[email protected]',
'name' => 'John Doe',
'status' => 'enabled',
]);
```### Example: Manage Lists
Get all lists:
```php
$lists = Listmonk::getLists();
```### Create a new list
```php
$newList = Listmonk::createList([
'name' => 'Weekly Newsletter',
'description' => 'Updates and news every week.',
]);
```## Facade
You can use the `Listmonk` facade to interact with the Listmonk API:
```php
use Theafolayan\ListmonkLaravel\Facades\Listmonk;$subscribers = Listmonk::getSubscribers();
$list = Listmonk::createList(['name' => 'New List']);
```## Dependency Injection
Alternatively, you can inject the Listmonk class into your services:
```php
use Theafolayan\ListmonkLaravel\Listmonk;
class YourService
{
protected $listmonk;public function __construct(Listmonk $listmonk)
{
$this->listmonk = $listmonk;
}public function getSubscribers()
{
return $this->listmonk->getSubscribers();
}
}
```## Methods
- `getSubscribers(array $filters = [])`
- `createSubscriber(array $data)`
- `getLists()`
- `createList(array $data)`## Contributing
Contributions are welcome! To contribute:
- Fork the repository.
- Create a feature branch.
- Submit a pull request.## License
This package is open-sourced software licensed under the [MIT license](https://opensource.org/license/mit).