Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Pushover Laravel Package

daltcore/pushover

Laravel package for sending Pushover.net notifications to iOS/Android. Includes a facade/service provider, simple push(title, message) API, and options for URL, callback, sound, and more. Configure with your app token and user key.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require daltcore/pushover
    

    Add the service provider to config/app.php:

    'providers' => [
        // ...
        DALTCORE\Pushover\PushoverServiceProvider::class,
    ],
    
  2. Configuration: Publish the config file:

    php artisan vendor:publish --provider="DALTCORE\Pushover\PushoverServiceProvider" --tag=config
    

    Update .env with your Pushover API token and user key:

    PUSHOVER_TOKEN=your_api_token
    PUSHOVER_USER_KEY=your_user_key
    
  3. First Use Case: Send a basic notification in a controller or command:

    use DALTCORE\Pushover\Pushover;
    
    public function sendNotification()
    {
        $pushover = app(Pushover::class);
        $pushover->send('Hello from Laravel!', 'This is a test message.');
    }
    

Implementation Patterns

Core Workflows

  1. Sending Notifications: Use the Pushover facade or injected service to send messages:

    Pushover::send('Title', 'Message body', [
        'priority' => 1, // 0 (lowest) to 2 (highest)
        'url' => 'https://example.com',
        'url_title' => 'View Details',
    ]);
    
  2. Integration with Laravel Events: Trigger notifications on events (e.g., user.registered):

    use DALTCORE\Pushover\Events\PushoverNotification;
    
    event(new PushoverNotification('User Registered', 'New user signed up: ' . $user->email));
    
  3. Queueing Notifications: Dispatch notifications to a queue (requires queue config):

    Pushover::queue('Title', 'Message', ['priority' => 1]);
    
  4. Dynamic Recipients: Fetch user keys from a database and loop through them:

    $admins = User::where('is_admin', true)->get();
    foreach ($admins as $admin) {
        Pushover::send('Alert', 'New issue reported', [], $admin->pushover_key);
    }
    

Advanced Patterns

  • Customizing Templates: Extend the Pushover class to add reusable templates:

    class CustomPushover extends Pushover {
        public function alert($message, $severity = 'warning') {
            $priority = $severity === 'critical' ? 2 : 1;
            $this->send('Alert: ' . $severity, $message, ['priority' => $priority]);
        }
    }
    
  • Logging Failures: Override the send method to log failed notifications:

    Pushover::extend(function ($app) {
        $pushover = new Pushover($app);
        $pushover->afterSend(function ($response, $data) {
            if ($response->failed()) {
                Log::error('Pushover failed', ['data' => $data, 'response' => $response]);
            }
        });
        return $pushover;
    });
    

Gotchas and Tips

Pitfalls

  1. Deprecated Laravel Version: The package was last updated in 2019 for Laravel 5.x. Test thoroughly in Laravel 8/9+ due to potential compatibility issues (e.g., dependency conflicts, facades).

  2. No Retry Logic: Failed notifications are not retried by default. Implement a queue job with exponential backoff for critical alerts:

    Pushover::queue('Title', 'Message')->onQueue('high')->delay(now()->addMinutes(1));
    
  3. Rate Limits: Pushover has rate limits. Cache user keys and batch notifications to avoid hitting limits.

  4. Missing Error Handling: The package lacks built-in error handling for invalid API tokens or user keys. Validate inputs:

    if (!config('pushover.token') || !config('pushover.user_key')) {
        throw new \RuntimeException('Pushover credentials not configured.');
    }
    

Debugging Tips

  • Check Responses: Log the raw response to debug issues:

    $response = Pushover::send('Title', 'Message');
    Log::debug('Pushover Response', ['status' => $response->status(), 'body' => $response->body()]);
    
  • Test with Sandbox: Use Pushover’s sandbox to test without real notifications.

  • Verify Endpoints: Ensure the PUSHOVER_URL in config is correct (defaults to https://api.pushover.net/1/messages.json).

Extension Points

  1. Custom HTTP Client: Replace the underlying HTTP client (e.g., for mocking in tests):

    Pushover::extend(function ($app) {
        $client = new \GuzzleHttp\Client(['base_uri' => config('pushover.url')]);
        return new Pushover($app, $client);
    });
    
  2. Add Attachments: Extend the package to support file attachments (Pushover API supports this via attachment parameter):

    $pushover->send('Download Available', 'New file ready', [
        'attachment' => Storage::disk('s3')->url('file.pdf'),
    ]);
    
  3. Multi-User Notifications: Create a helper method for broadcasting to multiple users:

    Pushover::extend(function ($app) {
        $pushover = new Pushover($app);
        $pushover->toMany = function ($title, $message, $userKeys) {
            foreach ($userKeys as $key) {
                $this->send($title, $message, [], $key);
            }
        };
        return $pushover;
    });
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
gmostafa/php-graphql-client
xeviant/paystack
snowsoft/faker
meditationsteps/blogetc
animalyoung/laravel-influxdb
onix-solutions/sms-telera
lonely-lights/prosetta
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log