roundly-consulting / campaigns-for-laravel
Send campaigns to multiple recipients
Package info
github.com/roundly-consulting/campaigns-for-laravel
pkg:composer/roundly-consulting/campaigns-for-laravel
Fund package maintenance!
Requires
- php: ^8.4
- illuminate/contracts: ^12.0|^13.0
- roundly-consulting/contacts-for-laravel: ^1.0
- roundly-consulting/enums-for-laravel: ^1.0
- roundly-consulting/options-for-laravel: ^1.0
- roundly-consulting/package-toolkit-for-laravel: ^1.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.18
- nunomaduro/collision: ^8.5
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpunit/phpunit: ^12.0
- roundly-consulting/testing-for-laravel: ^1.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Campaigns for Laravel
Send campaigns to many recipients through Laravel queues and job batches. Address them by email, contact record or contact owner, deliver by email, a Laravel notification or your own job, and keep campaigns in memory or in the database.
Installation
Requires PHP 8.4 and Laravel 12 or 13.
composer require roundly-consulting/campaigns-for-laravel php artisan vendor:publish --tag="campaigns-migrations" --tag="options-migrations" --tag="contacts-migrations" php artisan migrate
Every campaign runs as a job batch, so the app needs Laravel's job_batches table
(php artisan make:queue-batches-table if it has none) and a running queue worker. To follow
progress across requests, keep campaigns in the database rather than the default per-process
memory: CAMPAIGNS_STORE='RoundlyConsulting\Campaigns\Stores\DatabaseCampaignStore'.
Usage
Create, address and send a campaign through the facade, then follow its progress:
use RoundlyConsulting\Campaigns\Facades\Campaigns; $campaign = Campaigns::create('Buy today and spend less', '<p>Hello dear customer!</p>') ->from('no-reply@eshop.tld', 'Best E-Shop Ever') ->to(['john@doe.tld', 'jane@doe.tld']) // emails, Contact records or HasContacts owners ->dispatch(); // one queued delivery job per recipient $progress = Campaigns::campaign($campaign->uuid)->progress(); $progress->percentage(); // share delivered so far: 50.0 $progress->failed; // deliveries that failed $progress->remaining(); // recipients still to go Campaigns::cancel($campaign->uuid); // stop the rest
Documentation
The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/campaigns-for-laravel
Release notes are in CHANGELOG.md. To contribute, see the contributing guide.
Support our work
This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.
License
The MIT License (MIT). See LICENSE.md.