Installation
Requirements
| Requirement | Version |
|---|---|
| PHP | >= 8.0 |
| WordPress | >= 5.9 |
| wpzylos-core | ^1.0 |
| wpzylos-database | ^1.0 (optional) |
Composer Install
composer require KYNetCode/wpzylos-notification
Optional Dependencies
For database notifications (inbox pattern):
composer require KYNetCode/wpzylos-database
For advanced email sending:
composer require KYNetCode/wpzylos-mail
Register the Service Provider
Add the NotificationServiceProvider to your plugin's bootstrap:
use WPZylos\Framework\Notification\NotificationServiceProvider;
// In your plugin's main file or bootstrap:
$app->register(new NotificationServiceProvider());
The service provider automatically:
- Registers
NotificationManageras a singleton - Registers the
mailchannel (using MailManager if available, otherwisewp_mail()) - Registers the
databasechannel (ifwpzylos-databaseis installed) - Registers the
admin_noticechannel - Binds
DatabaseNotificationInstallerfor table creation - Hooks into
wpzylos_resolve_servicefilter for theNotifiabletrait
Database Setup
If using the DatabaseChannel, create the notifications table:
use WPZylos\Framework\Notification\DatabaseNotificationInstaller;
// During plugin activation:
register_activation_hook(__FILE__, function () use ($app) {
$installer = $app->make(DatabaseNotificationInstaller::class);
$installer->install();
});
// During plugin uninstallation (optional):
$installer->uninstall();
Verify Installation
$manager = $app->make(\WPZylos\Framework\Notification\NotificationManager::class);
// Check registered channels
var_dump($manager->channelNames());
// ['mail', 'database', 'admin_notice']