Cache-based repository for building simple dashboards with websockets

dev-master 2016-12-29 23:32 UTC

This package is not auto-updated.

Last update: 2020-07-05 17:29:19 UTC


A very simple monitoring system that could assist me in generating real-time websocket dashboards for client projects. The needs were as follows:

  1. 100% cache based. No DB hits.
  2. Easy setting and resetting of data
  3. Implementation with Pusher to push data out on a regular basis

This library does this in a very simple way.

  1. You add "sensors" via the db or php artisan commands. Sensors can be arrays or numbers.
  2. You then put the sensors wherever you want to include them in your code
  3. You set up a cron for the heartbeat (and also the setting or resetting of data if you want)
  4. You set up an html page that listens for the "heartbeat"


1. Run the migration

2. Add this to your config app.php


3. Optional: Add this to your config app.php to load the included helpers


Client Side

	<script src=""></script>
        var pusher = new Pusher('YOUR-KEY');
		var pusherChannel_1 = pusher.subscribe('pulse_group_1');
	    pusherChannel_1.bind('heartbeat', function(event) {

Basic Server-Side Usage

    // from the command line, build a sensor.  Behind the scenes, this simply adds a table to the database and regenerates the cache of sensors
    >> php artisan pulse:create_sensor "Conversions Today"
        // set the value manually
        // or just increment by 1

Advanced Server-Side Usage

// Sample cron to push all events in group 1 for one minute, resting each second between pushes (ie: 60 times per minute)
    ->command('pulse:heartbeat --group 1 --sleep 1')

// Sample cron to reset all hourly-based sensors (you can use hourly, daily, weekly, monthly, yearly)
$schedule->call(function () {

$schedule->call(function () {

// this is an example that pushes items into a sensor array on a regular basis (useful for known how many people are currently online or something similar).
$schedule->call(function () {
    foreach (\App\Models\Users\Agents::all() as $agent) {

Known Limitations

Right now, the code works only with Pusher (it uses Pusher's syntax). I should probably use broadcasters that use laravel's broadcasters interface, but just didn't need to yet, as we have historically used Pusher as our broadcaster.


Scott Laurent, Michael Paas