birkof/onesignal-bundle
Symfony bundle integrating the norkunas/onesignal-php-api library. Configure your OneSignal application/user keys and use the onesignal.api service from the container to manage notifications and other OneSignal API resources.
Architecture Fit
The birkof/onesignal-bundle is a Symfony bundle, not natively Laravel-compatible, but its underlying library (norkunas/onesignal-php-api) can be leveraged in Laravel via manual integration or Symfony bridge packages (e.g., symfony/bundle). Key considerations:
config.yml) may need Laravel config file (config/onesignal.php) adapters.ContainerInterface.Integration Feasibility
norkunas/onesignal-php-api) is PHP-agnostic. Feasibility depends on:
OneSignal::api()).config.yml with Laravel’s config/onesignal.php.Bus or Events to trigger OneSignal notifications (e.g., user.registered → send welcome push).symfony/http-client). Test for conflicts with Laravel’s illuminate/http.Technical Risk
Kernel, EventDispatcher, or DependencyInjection, requiring polyfills or custom implementations in Laravel.norkunas/onesignal-php-api directly (skip the bundle) to avoid Symfony dependencies.HttpClient instead of Symfony’s HttpClient.Key Questions
OneSignalBundle class extend Symfony’s Bundle in a way that’s incompatible with Laravel’s ServiceProvider?auth.login) without tight coupling?norkunas/onesignal-php-api library?Stack Fit
Migration Path
Option A: Use the Bundle (Symfony) with Laravel
composer require birkof/onesignal-bundle
OneSignalBundle:
// app/Providers/OneSignalServiceProvider.php
public function register()
{
$this->app->singleton('onesignal.api', function ($app) {
return new \Adelplace\OneSignalBundle\Service\OneSignalApi(
config('onesignal.application_id'),
config('onesignal.auth_key')
);
});
}
config.yml with Laravel’s config/onesignal.php:
// config/onesignal.php
return [
'application_id' => env('ONESIGNAL_APP_ID'),
'auth_key' => env('ONESIGNAL_AUTH_KEY'),
];
EventDispatcher) may fail.Option B: Use Underlying Library Directly
composer require norkunas/onesignal-php-api
// app/Helpers/OneSignal.php
use Norkunas\OneSignal\OneSignal;
class OneSignalHelper {
public static function sendNotification($title, $message, $includePlayerIds = []) {
$api = new OneSignal(
config('onesignal.application_id'),
config('onesignal.auth_key')
);
return $api->notifications->create($title, $message, $includePlayerIds);
}
}
Compatibility
HttpClient) may need replacements..env keys match the bundle’s expected config (e.g., ONESIGNAL_APP_ID).Mockery or PHPUnit to test OneSignal interactions without hitting the real API.Sequencing
getAll(), create()).registered, password.reseted).// app/Listeners/SendWelcomePush.php
public function handle($event) {
OneSignalHelper::sendNotification(
'Welcome!',
'Thanks for registering!',
[$event->user->device_id]
);
}
ShouldQueue job to avoid blocking requests.// app/Jobs/SendPushNotification.php
public function handle() {
$api->notifications->create($this->title, $this->message, $this->players);
}
Maintenance
config/onesignal.php simplifies management vs. Symfony’s config.yml.telescope, laravel-debugbar).norkunas/onesignal-php-api may introduce breaking changes (monitor GitHub issues).Support
norkunas/onesignal-php-api) for updates.try {
$api->notifications->create(...);
} catch (\Norkunas\OneSignal\Exception\OneSignalException $e) {
Log::error("OneSignal failed: " . $e->getMessage());
// Retry or notify admins
}
Scaling
sendToMultiple) for bulk notifications.device_ids in Laravel’s users table for targeting.Failure Modes
failed_jobs table.retryAfter() in jobs.application_id/auth_key will fail silently.How can I help you explore Laravel packages today?