定制 cravler/faye-app-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cravler/faye-app-bundle

Composer 安装命令:

composer require cravler/faye-app-bundle

包简介

无描述信息

README 文档

README

This bundle depends on faye-app.

Installation

Step 1: Download the Bundle

composer require cravler/faye-app-bundle:2.x-dev

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the Bundle

This bundle should be automatically enabled by Flex. In case you don't use Flex, you'll need to manually enable the bundle by adding the following line in the config/bundles.php file of your project:

<?php
// config/bundles.php

return [
    // ...
    Cravler\FayeAppBundle\CravlerFayeAppBundle::class => ['all' => true],
];

Step 3: Add routing

# config/routes.yaml

cravler_faye_app:
    resource: "@CravlerFayeAppBundle/Resources/config/routing.yaml"

Step 4: Include Javascript

To include the relevant javascript libraries necessary for FayeApp, add these to your root layout file.

<!-- .../Acme/DemoBundle/Resources/views/layout.html.twig -->

<script type="text/javascript" src="..."></script>
{{ faye_app_javascript() }}

Usage

Create entry-point

<?php
// .../Acme/DemoBundle/EntryPoint/Example.php

namespace Acme\DemoBundle\EntryPoint;

use Cravler\FayeAppBundle\EntryPoint\AbstractEntryPoint;

class Example extends AbstractEntryPoint
{
    public function getId()
    {
        return 'acme-demo.example';
    }
}

Register entry-point

<!-- .../Acme/DemoBundle/Resources/config/services.xml -->

<services>
    ...
    <service id="acme.demo.entry_point.example" class="Acme\DemoBundle\EntryPoint\Example">

        <call method="setEntryPointManager">
            <argument type="service" id="cravler_faye_app.service.entry_point_manager" />
        </call>

        <tag name="cravler_faye_app.entry_point" />
    </service>
    ...
</services>

Subscribing to channels

<script type="text/javascript">
    var exampleEntryPoint = FayeApp.createEntryPoint('acme-demo.example');

    var subscription = exampleEntryPoint.subscribe('/foo', function(message) {
        console.log('[foo] Handle message: ', message);
    });

    subscription.then(function() {
        console.log('[foo] Subscription is now active!');
    }, function(error) {
        console.log('[foo] Subscription problem: ' + error.message);
    });
</script>

Sending messages

<script type="text/javascript">
    var exampleEntryPoint = FayeApp.createEntryPoint('acme-demo.example');

   var publication = exampleEntryPoint.publish('/foo', { text: 'Hi there' });

   publication.then(function() {
       console.log('[foo] Message received by server!');
   }, function(error) {
       console.log('[foo] There was a problem: ' + error.message);
   });
</script>

Configuration

The default configuration for the bundle looks like this:

cravler_faye_app:
    example: false
    user_provider: false #security.user.provider.concrete.[provider_name]
    route_url_prefix: /faye-app
    use_request_uri: false
    secret: ThisTokenIsNotSoSecretChangeIt
    app:
        scheme: ~
        host: 127.0.0.1
        port: ~
        mount: /pub-sub
        options: {}

License

This bundle is under the MIT license. See the complete license in the bundle:

LICENSE

统计信息

  • 总下载量: 53.58k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 未知

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固