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

Sse Laravel Package

hosmelq/sse

WHATWG-compliant PHP 8.2+ client for consuming Server-Sent Events. Connect via GET/POST using Guzzle, iterate events with a memory-efficient generator, and access data/event/id/retry fields with optional JSON decoding.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Real-time feature acceleration: Enables rapid development of live updates (e.g., notifications, dashboards, or collaborative tools) without WebSocket complexity. Aligns with roadmap items requiring sub-second latency or event-driven architectures.
  • Third-party API integration: Simplifies consuming SSE streams from services like Twitch, GitHub, or custom APIs, reducing backend boilerplate for parsing data:, event:, or id: fields.
  • Build vs. buy tradeoff: Justifies not reinventing SSE parsing logic in PHP, saving 2–4 weeks of dev time for compliant implementations. Ideal for teams prioritizing speed over customization.
  • Microservices decoupling: Facilitates serverless functions or Kubernetes pods consuming SSE streams (e.g., processing IoT data or logs) without shared state.
  • Use cases:
    • Frontend sync: Backend consumption of SSE for Laravel Livewire/Inertia real-time updates.
    • Legacy modernization: Bridging older PHP systems to modern real-time frontends (e.g., replacing polling with SSE).
    • Testing/QA: Simulating SSE endpoints for frontend development or automated UI tests.

When to Consider This Package

  • Adopt if:

    • Your PHP backend only needs to consume (not emit) SSE streams (use Laravel’s Sse facade for emission).
    • You require WHATWG compliance for seamless browser integration (e.g., frontend JavaScript consuming the same stream).
    • Memory efficiency is critical (generator-based iteration avoids loading entire streams into memory).
    • Your team lacks SSE protocol expertise (handles id, event, retry fields automatically).
    • You’re using PHP 8.2+ and can leverage Composer (low friction for adoption).
    • The use case involves long-lived connections (e.g., stock tickers, live sports scores) where HTTP/2 or WebSockets would be overkill.
  • Look elsewhere if:

    • You need bidirectional communication (use WebSockets via Ratchet, BeyondCode/Laravel WebSockets, or Pusher).
    • Your PHP version is <8.2 (requires upgrade or alternative like symfony/server-sent-event).
    • The package’s low adoption (14 stars, 0 dependents) raises concerns about long-term maintenance (mitigate by evaluating HosmelQ’s GitHub activity or forking).
    • You require advanced features like:
      • Authentication middleware (e.g., OAuth tokens per event).
      • Reconnection logic (beyond Last-Event-ID; may need custom extensions).
      • Load balancing for high-throughput streams (Guzzle’s default connection pooling may need tuning).
    • Your stack includes non-PHP services (e.g., Node.js, Go) where native SSE libraries (e.g., eventsource for JS) are preferred.

How to Pitch It (Stakeholders)

For Executives: "This package lets us consume real-time data streams (e.g., live notifications, stock updates) with minimal engineering overhead. By leveraging WHATWG-compliant SSE, we ensure seamless integration with modern browsers—reducing frontend complexity and accelerating feature delivery. The memory-efficient design keeps costs low for high-volume streams, and the MIT license eliminates vendor lock-in. Initial adoption is low-risk, with potential to cut development time by 30% for real-time features. Let’s prioritize this for [X initiative] where it aligns with our roadmap."

For Engineering: *"The hosmelq/sse package provides a production-ready way to consume SSE streams in PHP, handling edge cases like reconnection (Last-Event-ID) and protocol violations out of the box. Key advantages:

  • Drop-in simplicity: Replace manual SSE parsing with foreach ($events as $event).
  • Laravel synergy: Works with the built-in Http client or Guzzle for custom timeouts/headers.
  • Robust error handling: Clear exceptions (SSEConnectionException, SSEProtocolException) for debugging.
  • Memory efficiency: Generator-based iteration avoids loading entire streams.

Tradeoffs:

  • Limited to consumption (not emission); pair with Laravel’s Sse facade for full real-time workflows.
  • Requires Artisan commands or queue workers for long-lived connections (not ideal for request-bound Laravel routes).

Recommendation: Evaluate for use cases like [live dashboards, IoT data processing, or third-party API integration]. Start with a proof-of-concept in an Artisan command to validate integration with Laravel’s event system or queues."*

For Security/Compliance: *"The package’s MIT license and WHATWG compliance align with modern web standards. However, note:

  • No built-in auth: SSE endpoints must handle authentication (e.g., via headers or tokens).
  • Connection persistence: Long-lived streams may require TLS termination or WAF rules for production. Mitigation: Use Laravel’s Http client middleware for auth and monitor connections via Laravel Horizon or custom metrics."*
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.
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
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope