lzaztec / notification-bundle
This Bundle integrates Dklab Realplexor comet server (or other) functionality into a Symfony2 project.
Installs: 309
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.0
- dklab/realplexor: >=1.41
This package is not auto-updated.
Last update: 2024-04-13 13:09:42 UTC
README
This bundle provides intergration with a Dklab Realplexor (or other) comet server
Installation
For Symfony >2.1:
add to your composer.json
file:
/// 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
For Symfony 2.0.x:
add to your application deps
file:
[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:
// app/AppKernel.php public function registerBundles() { return array( // ... new LZAztec\NotificationBundle\LZAztecNotificationBundle(), // ... ); }
add to your apllication autoload.php
file:
// app/autoload.php $loader->registerNamespaces(array( // ... 'LZAztec' => __DIR__.'/../vendor/bundles', )); $loader->registerPrefixes(array( // ... // Load realplexor api 'Dklab_' => __DIR__.'/../vendor/Dklab/Reaplexor/api/php', ));
Configuration
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
Usage
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.
<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>