This Bundle integrates Dklab Realplexor comet server (or other) functionality into a Symfony2 project.
This bundle provides intergration with a Dklab Realplexor (or other) comet server, (*1)
add to your composer.json
file:, (*2)
/// composer.json "require": { // ... "lzaztec/notification-bundle": "dev-master" }, "repositories": [ // ... { "type":"package", "package":{ "name":"dklab/realplexor", "version": "1.41", "source":{ "type":"git", "url":"https://github.com/DmitryKoterov/dklab_realplexor", "reference":"master" }, "autoload":{ "classmap":["api/php/Dklab/"] } } } ]
and run composer update lzaztec/notification-bundle
, (*3)
add to your application deps
file:, (*4)
[DklabRealplexor] git=https://github.com/DmitryKoterov/dklab_realplexor.git target=/Dklab/Reaplexor [LZAztecNotificationBundle] git=https://github.com/LZAztec/LZAztecNotificationBundle.git target=/bundles/LZAztec/NotificationBundle
add to your apllication AppKernel.php
file:, (*5)
// app/AppKernel.php public function registerBundles() { return array( // ... new LZAztec\NotificationBundle\LZAztecNotificationBundle(), // ... ); }
add to your apllication autoload.php
file:, (*6)
// app/autoload.php $loader->registerNamespaces(array( // ... 'LZAztec' => __DIR__.'/../vendor/bundles', )); $loader->registerPrefixes(array( // ... // Load realplexor api 'Dklab_' => __DIR__.'/../vendor/Dklab/Reaplexor/api/php', ));
lz_aztec_notification: realplexor_ns: demo_ # Realplexor namespace to use (allowed alphanumeric characters and the underscore character) js_api_host: notify.localhost # JS API host to listen for notifications
Function init_notification()
takes only one parameter, which will contain an instance of notification controller class.
To initialize scripts put code {{ init_notification('varName') }}
AFTER jquery initialization, next you need to subscribe channel and start listen it., (*7)
<script type="text/javascript" src="path/to/jquery.min.js"></script> {{ init_notification('varName') }} <script type="text/javascript"> $(document).ready(function(){ varName.subscribeChannel('ChannelName'); varName.startListen(); }); </script>