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

dyaa/pushover

Laravel 5 package for sending Pushover.net notifications to iOS/Android. Configure your app token and user key, then use a simple Facade API to push messages and optionally set URL, callback, sound, and more.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require dyaa/pushover:dev-master
    

    Add the service provider to config/app.php:

    'providers' => [
        // ...
        Dyaa\Pushover\PushoverServiceProvider::class,
    ],
    
  2. Publish Config:

    php artisan vendor:publish --provider="Dyaa\Pushover\PushoverServiceProvider"
    

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

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

    use Dyaa\Pushover\Facades\Pushover;
    
    Pushover::send('Hello from Laravel!', 'This is your first Pushover message.');
    

Implementation Patterns

Core Workflows

  1. Basic Notifications:

    Pushover::send('Title', 'Message body', [
        'priority' => 1, // 0 (quiet) to 2 (loud)
        'url' => 'https://example.com',
        'url_title' => 'View Details',
    ]);
    
  2. Grouped Notifications:

    Pushover::sendToGroup('GroupName', 'Title', 'Message');
    
  3. Silent Notifications (Priority 0):

    Pushover::send('Low Priority', 'This won\'t make a sound.', ['priority' => 0]);
    
  4. Integration with Events:

    // In an Event class
    public function handle()
    {
        Pushover::send('Event Triggered', 'User ' . $this->user->name . ' performed action.');
    }
    
  5. Queueing Notifications:

    Pushover::queue('Title', 'Message'); // Uses Laravel's queue system
    

Advanced Patterns

  • Dynamic Recipients:

    $users = User::where('is_admin', true)->get();
    foreach ($users as $user) {
        Pushover::sendToUser($user->pushover_key, 'Alert', 'New admin activity detected.');
    }
    
  • Conditional Notifications:

    if ($user->prefers_pushover) {
        Pushover::send('Welcome', "Hi {$user->name}, you're all set up!");
    }
    
  • Logging Failures:

    try {
        Pushover::send('Critical Alert', 'Server down!');
    } catch (\Exception $e) {
        Log::error("Pushover failed: " . $e->getMessage());
    }
    

Gotchas and Tips

Common Pitfalls

  1. Deprecated Laravel Version:

    • The package is archived and last updated for Laravel 5. The dev-master branch may not be fully compatible with newer Laravel versions (e.g., 8+). Test thoroughly or fork the repo for updates.
  2. Missing .env Configuration:

    • Forgetting to publish the config or set PUSHOVER_API_TOKEN/PUSHOVER_USER_KEY will cause silent failures. Verify with:
      if (!config('pushover.api_token')) {
          throw new \RuntimeException('Pushover API token not configured.');
      }
      
  3. Priority Overrides:

    • Pushover’s default priority is 1. Explicitly set priority to avoid unexpected loud notifications:
      Pushover::send('Alert', 'Message', ['priority' => 0]); // Quiet
      
  4. Queue Stuck Jobs:

    • If using queues, ensure the pushover queue connection is properly configured in config/queue.php. Monitor failed jobs in failed_jobs table.
  5. Rate Limiting:

    • Pushover has rate limits. Avoid spamming the API in loops. Implement delays or batch processing:
      foreach ($notifications as $notification) {
          Pushover::send($notification['title'], $notification['message']);
          sleep(1); // 1-second delay between messages
      }
      

Debugging Tips

  • Enable Debugging: Add to config/pushover.php:

    'debug' => env('PUSHOVER_DEBUG', false),
    

    This logs raw API responses to storage/logs/pushover.log.

  • Test with a Dummy Token: Use Pushover’s sandbox token during development to avoid hitting real limits.

  • Check HTTP Client: The package uses Laravel’s HTTP client. Verify no middleware (e.g., TrustProxies) interferes with the request.

Extension Points

  1. Customize the HTTP Client: Override the default client in a service provider:

    $this->app->singleton(\Illuminate\Http\Client\Factory::class, function ($app) {
        return \Illuminate\Http\Client\PendingRequest::macro('pushover', function () {
            return $this->withOptions(['debug' => true]);
        });
    });
    
  2. Add Custom Fields: Extend the Pushover facade to support additional Pushover API fields (e.g., sound, timestamp):

    // In a custom facade class
    public function sendWithSound($message, $sound = 'magic')
    {
        return $this->send($message, null, ['sound' => $sound]);
    }
    
  3. Mock for Testing: Use Laravel’s HTTP mocking in tests:

    $this->mock(\Illuminate\Http\Client\PendingRequest::class)
        ->shouldReceive('post')
        ->once()
        ->andReturnResponse();
    
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.
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
renatovdemoura/blade-elements-ui