Pros:
Mail, Cache).OneSignal façade into services/controllers).Cons:
Laravel Compatibility:
OneSignal Dependencies:
.env or config files; mitigate with Laravel’s env() or vault solutions.Database/ORM:
User::where('is_active', true)).| Risk Area | Severity | Mitigation |
|---|---|---|
| OneSignal API rate limits | High | Implement retries (e.g., Laravel’s retry helper) and monitor usage via OneSignal dashboard. |
| Synchronous call bottlenecks | Medium | Offload to Laravel queues (bus:listen) or use OneSignal’s async APIs. |
| Key rotation | Medium | Use Laravel’s config/caching or environment variable rotation tools. |
| Package abandonment | Low | Monitor GitHub activity; fork if inactive (524 stars suggest moderate adoption). |
| Feature gaps | Low | Extend via service layer or direct OneSignal API calls where needed. |
dev/stage/prod? Use Laravel’s config/environments or a secrets manager.Laravel Ecosystem:
OneSignalServiceProvider (auto-discovered in Laravel ≥5.5), binding OneSignal façade to Berkayk\OneSignal\OneSignalManager.OneSignal into controllers/services (e.g., use OneSignal; or via constructor DI).php artisan vendor:publish --tag=onesignal-config) to customize API keys, endpoints, or defaults.OneSignal Integration:
Extensions:
OneSignal façade to dispatch jobs (e.g., SendNotificationJob) for async processing.NotificationSent) for analytics or side effects.MockFacade or HTTP tests to stub OneSignal API calls.Prerequisites:
Installation:
composer require berkayk/onesignal-laravel
php artisan vendor:publish --tag=onesignal-config # Publish config
.env:
ONESIGNAL_APP_ID=your_app_id
ONESIGNAL_REST_API_KEY=your_rest_key
Basic Usage:
// Broadcast to all users
OneSignal::sendNotification([
'contents' => ['en' => 'Hello!'],
'headings' => ['en' => 'Notification Title'],
]);
// Target specific user
OneSignal::sendNotificationToUser($userId, [
'contents' => ['en' => 'Your order is shipped!'],
]);
Advanced Integration:
// Decorate façade or create a job
class SendOneSignalJob implements ShouldQueue {
public function handle() {
OneSignal::sendNotification(...);
}
}
composer.json for exact ranges).spatie/laravel-package-tools by default).curl and json (standard in PHP)..env, and implement basic broadcasts/targeted pushes.berkayk/onesignal-laravel for updates (check GitHub releases).composer.json to avoid breaking changes (e.g., ^1.0)..env).tap):
OneSignal::sendNotification(...)->tap(function ($response) {
Log::debug('OneSignal response', $response);
});
How can I help you explore Laravel packages today?