|
1 | | -This SDK is organized around resources. |
| 1 | +# Listmonk PHP |
2 | 2 |
|
3 | | -## Usage |
| 3 | +A PHP SDK for the [Listmonk](https://listmonk.app) email platform. |
| 4 | + |
| 5 | +[](https://github.com/dynamik-dev/listmonk-php/actions/workflows/CI.yml) |
| 6 | + |
| 7 | +## Requirements |
| 8 | + |
| 9 | +- PHP 8.4+ |
| 10 | + |
| 11 | +## Installation |
| 12 | + |
| 13 | +```bash |
| 14 | +composer require dynamik-dev/listmonk-php |
| 15 | +``` |
| 16 | + |
| 17 | +## Quick Start |
4 | 18 |
|
5 | 19 | ```php |
6 | 20 | use DynamikDev\Listmonk\Listmonk; |
7 | 21 |
|
8 | 22 | $listmonk = new Listmonk( |
9 | 23 | baseUrl: 'https://listmonk.example.com', |
10 | | - username: 'admin', |
11 | | - password: 'secret', |
| 24 | + username: 'api', |
| 25 | + password: 'your-api-token', |
12 | 26 | ); |
13 | 27 | ``` |
14 | 28 |
|
15 | | -Create a subscriber: |
| 29 | +### Create a subscriber |
16 | 30 |
|
17 | 31 | ```php |
18 | | -$listmonk->subscribers()->create( |
| 32 | +$subscriber = $listmonk->subscribers()->create( |
19 | 33 | email: 'user@example.com', |
20 | 34 | name: 'John Doe', |
21 | 35 | lists: [1, 2], |
22 | 36 | ); |
23 | 37 | ``` |
24 | 38 |
|
25 | | -Get all campaigns: |
| 39 | +### Send a campaign |
| 40 | + |
| 41 | +```php |
| 42 | +$campaign = $listmonk->campaigns()->create( |
| 43 | + name: 'Welcome Campaign', |
| 44 | + subject: 'Welcome to our newsletter!', |
| 45 | + lists: [1], |
| 46 | + body: '<p>Hello {{ .Subscriber.Name }}!</p>', |
| 47 | +); |
| 48 | + |
| 49 | +$listmonk->campaigns()->start($campaign->id); |
| 50 | +``` |
| 51 | + |
| 52 | +### Public subscription (no auth required) |
26 | 53 |
|
27 | 54 | ```php |
28 | | -$listmonk->campaigns()->list(); |
| 55 | +$listmonk->public()->subscribe( |
| 56 | + email: 'user@example.com', |
| 57 | + name: 'John Doe', |
| 58 | + listUuids: ['abc-123-def'], |
| 59 | +); |
29 | 60 | ``` |
| 61 | + |
| 62 | +## Documentation |
| 63 | + |
| 64 | +For full documentation, visit [docs.dynamik.dev/listmonk-php](https://docs.dynamik.dev/listmonk-php) |
| 65 | + |
| 66 | +## License |
| 67 | + |
| 68 | +MIT |
0 commit comments