Weave Code
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

by-nativ/pushover

Laravel 5 package for sending push notifications via Pushover.net to iOS and Android. Provides a simple facade to push messages with optional title, URL, callback, and sound, using your Pushover app token and user key configuration.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require by-nativ/pushover
    

    Publish the config file:

    php artisan vendor:publish --provider="ByNativ\Pushover\PushoverServiceProvider"
    
  2. Configuration Edit .env with your Pushover API token and user key:

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

    use ByNativ\Pushover\Pushover;
    
    public function sendNotification()
    {
        Pushover::send('Hello from Laravel!');
    }
    

Implementation Patterns

Core Workflows

  1. Basic Notifications

    Pushover::send('Message', [
        'title' => 'Alert',
        'priority' => 1, // 0-2 (lowest to highest)
    ]);
    
  2. Attachments

    Pushover::send('Check this out!', [
        'attachment' => [
            'url' => 'https://example.com/image.png',
            'content_type' => 'image/png',
        ],
    ]);
    
  3. Conditional Sending

    if (config('app.debug_mode')) {
        Pushover::send('Debug alert!', ['priority' => 2]);
    }
    
  4. Queueing Notifications

    Pushover::queue('Scheduled alert', ['priority' => 1]);
    

Integration Tips

  • Logging: Use Laravel’s logging to track failed notifications:
    try {
        Pushover::send('Message');
    } catch (\Exception $e) {
        \Log::error('Pushover failed: ' . $e->getMessage());
    }
    
  • Environment-Specific Config: Override .env values per environment (e.g., PUSHOVER_TOKEN_STAGING).
  • Customizing Defaults: Extend the config file to set defaults for all notifications:
    'defaults' => [
        'priority' => 0,
        'retry' => 30,
    ],
    

Gotchas and Tips

Pitfalls

  1. Rate Limits: Pushover enforces a 1 message/second limit. Queue notifications for bursts:
    Pushover::queue('High-volume alert');
    
  2. Silent Failures: The package doesn’t throw exceptions by default. Enable strict mode in config:
    'strict' => true,
    
  3. Attachment Size: Pushover has a 5MB limit for attachments. Validate file sizes before sending.

Debugging

  • Verify API Keys: Test keys manually via Pushover’s API tester.
  • Check Response Codes: Log the raw response for errors:
    $response = Pushover::send('Test', [], true); // Enable debug mode
    \Log::debug($response);
    
  • Common Errors:
    • 401: Invalid token/user key.
    • 400: Malformed request (e.g., missing message).

Extension Points

  1. Custom Transport: Override the HTTP client in config/pushover.php:
    'client' => \Illuminate\Support\Facades\Http::macro('override', function () {
        return new \GuzzleHttp\Client(['timeout' => 10]);
    }),
    
  2. Event Listeners: Trigger notifications on events:
    event(new \App\Events\DeploymentFailed);
    // In listener:
    Pushover::send('Deployment failed!');
    
  3. Dynamic Recipients: Fetch user keys from a database:
    $users = User::where('notifications_enabled', true)->get();
    foreach ($users as $user) {
        Pushover::send('Alert', [], $user->pushover_key);
    }
    
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.
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours