Installation

Requirements

RequirementVersion
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:

  1. Registers NotificationManager as a singleton
  2. Registers the mail channel (using MailManager if available, otherwise wp_mail())
  3. Registers the database channel (if wpzylos-database is installed)
  4. Registers the admin_notice channel
  5. Binds DatabaseNotificationInstaller for table creation
  6. Hooks into wpzylos_resolve_service filter for the Notifiable trait

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']