lzaztec/notification-bundle

此Bundle将Dklab Realplexor comet服务器(或其他)功能集成到Symfony2项目中。

安装: 309

依赖: 0

建议者: 0

安全: 0

星标: 1

关注者: 1

分支: 0

开放问题: 0

类型:symfony-bundle

dev-master 2014-04-14 13:18 UTC

This package is not auto-updated.

Last update: 2024-09-28 15:29:46 UTC


README

此Bundle提供与Dklab Realplexor(或其他)comet服务器的集成

安装

对于Symfony >2.1

将以下内容添加到您的composer.json文件中

    /// 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/"]
                }
            }
        }
    ]

然后运行composer update lzaztec/notification-bundle

对于Symfony 2.0.x

将以下内容添加到您的应用deps文件中

[DklabRealplexor]
    git=https://github.com/DmitryKoterov/dklab_realplexor.git
    target=/Dklab/Reaplexor

[LZAztecNotificationBundle]
    git=https://github.com/LZAztec/LZAztecNotificationBundle.git
    target=/bundles/LZAztec/NotificationBundle

将以下内容添加到您的应用AppKernel.php文件中

    // app/AppKernel.php

    public function registerBundles()
    {
        return array(
            // ...
            new LZAztec\NotificationBundle\LZAztecNotificationBundle(),
            // ...
        );
    }

将以下内容添加到您的应用autoload.php文件中

    // 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

用法

函数init_notification()只接受一个参数,该参数将包含通知控制器类的实例。要将代码初始化脚本放入{{ init_notification('varName') }},请将其放在jQuery初始化之后,然后您需要订阅频道并开始监听它。

    <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>