Skip to content

Instantly share code, notes, and snippets.

@chanmix51
Last active August 29, 2015 14:09
Show Gist options
  • Save chanmix51/c4a0bfc9284138be0d25 to your computer and use it in GitHub Desktop.
Save chanmix51/c4a0bfc9284138be0d25 to your computer and use it in GitHub Desktop.
Using the observer with Pomm 2.
<?php // observer.php
require __DIR__.'/vendor/autoload.php';
use PommProject\Foundation\Pomm;
// Edit the dsn with your database settings and credentials
$pomm = new Pomm(['my_db' => ['dsn' => 'pgsql://greg/greg']]);
do {
do {
sleep(1);
$notification = $pomm['my_db']
->getObserver('pika')
->getNotification()
;
} while ($notification === null);
printf("%s\n", $notification['payload']);
} while ($notification['payload'] !== 'stop');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment