Skip to content

Instantly share code, notes, and snippets.

@chanmix51
Last active April 16, 2016 15:12
Show Gist options
  • Save chanmix51/7115363 to your computer and use it in GitHub Desktop.
Save chanmix51/7115363 to your computer and use it in GitHub Desktop.
<?php
// This file listen to notifications from the Postgresql server.
// To send a notification with a payload you can either issue a NOTIFY SQL command from a psql console
// or use the file below.
// pomm https://github.com/chanmix51/Pomm
$database = new \Pomm\Connection\Database([ "dsn" => "pgsql://user:pass@host:port/name" ]);
$observer = $database->getConnection()
->createObserver()
->listen('plop');
while (true)
{
while(!$data = $observer->getNotification())
{
printf(".");
sleep(1);
}
printf("x\n");
var_dump($data);
}
<?php
$database = new \Pomm\Connection\Database([ "dsn" => "pgsql://user:pass@host:port/name" ]);
$database->getConnection()->notify('plop', 'some data');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment