I built a plug-and-play SSE module for CodeIgniter 4 to make real-time notifications easy and clean. It installs via Composer and Spark, streams events from cache, and is perfect for dashboards or alerts. Open-source, simple, and ready for feedback.
If you've ever wanted real-time updates in your CodeIgniter 4 app without diving into the complexity of WebSockets, I’ve just released something that might help: a lightweight Server-Sent Events (SSE) module for CI4. I built this because I use SSE a lot myself—ideal for notifications, background job alerts, and sensor updates—and I wanted a clean, repeatable way to drop it into any CI4 project without fuss. You can find it on GitHub and install it via composer.
The goal was simplicity. After running composer require 0ruialvel0/codeigniter4-sse and php spark sse:install, the module sets up everything you need: a client-side JS listener, environment variables, and the controller that handles the event push logic. You can trigger events by writing to the cache—literally just cache()->save('event_cache_key', '1')—and the module takes care of streaming that to the browser. It’s unidirectional, so it’s perfect for things like “new order placed” alerts or “background job completed” messages, without needing the client to poll the server.
I’ve tried to make the install and uninstall process as clean as possible. The Spark installer edits your .env file automatically, and the uninstaller rolls those changes back. You can define multiple events in .env and match them with listeners in your JS. There’s even a basic example in the README that shows how to trigger a browser alert when an event fires—great for testing or quick prototyping.
This is still evolving, and I’d love for others to try it out, contribute, or open issues if something’s unclear or could be improved. I’m planning to add PHPUnit tests for stream output and config parsing soon, mostly because I want to learn more about testing in CI4. If you’re curious about SSE or just want a drop-in way to add reactive behavior to your app, give it a spin. And if you do use it, let me know how it goes—I’m always looking for feedback to make things smoother for fellow developers.