tiitoo/kijho-chat

维护者

详细信息

github.com/TiiToo/kijho-chat

源代码

安装: 2

依赖项: 0

建议者: 0

安全性: 0

星级: 0

关注者: 1

分支: 2

语言:CSS

类型:symfony-bundle

1.0.0 2016-08-17 20:11 UTC

This package is auto-updated.

Last update: 2024-09-04 10:38:40 UTC


README

聊天功能包

适用于 Symfony 2.8 和 3.x 的聊天插件

预览

管理面板截图:local.loc/app_dev.php/chat/admin alt tag 客户端面板截图:local.loc/app_dev.php/chat/client alt tag

安装

步骤 1:下载包

打开命令行控制台,进入您的项目目录,并执行以下命令以下载此包的最新稳定版本

$ composer require kijho/kijho-chat dev-master

此命令要求您全局安装 Composer,如 Composer 文档的《安装章节》所述。

步骤 2:启用包

然后,通过将其添加到项目中 app/AppKernel.php 文件中注册的包列表中启用该包

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new Gos\Bundle\WebSocketBundle\GosWebSocketBundle(), //bundle websockets for chat
            new Gos\Bundle\PubSubRouterBundle\GosPubSubRouterBundle(), //bundle websockets for chat
            new Kijho\ChatBundle\ChatBundle(),
        );

        // ...
    }

    // ...
}

为了看到视图,该包提供了一个实现。

将路由导入到您的 routing.yml

chat:
    resource: "@ChatBundle/Resources/config/routing.yml"
    prefix:   /{_locale}/chat

您必须将 FrchoCrontaskBundle 添加到资产配置 assetic.bundle

assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    bundles:        [ChatBundle]
    #java: /usr/bin/java
    filters:
        cssrewrite: ~
        #closure:

启用地区

framework:
    translator:      { fallbacks: ["%locale%"] }

WebSocket 配置

gos_web_socket:
    shared_config: true
    server:
        port: 5555                #The port the socket server will listen on
        host: 127.0.0.1           #The host ip to bind to
        router:
            resources:
                - "@ChatBundle/Resources/config/routing/chat.yml"

更新数据库模式和资产

symfony 3.0
bin/console doctrine:schema:update --force
bin/console assets:install
bin/console assetic:dump

symfony 2.8
app/console doctrine:schema:update --force
app/console assets:install
app/console assetic:dump

启动服务器

WebSocket 服务器端的安装现在已完成。您应该能够从 Symfony 安装根目录运行此服务器。

php app/console gos:websocket:server

如果一切顺利,您将看到以下类似的内容

Starting Gos WebSocket
Launching Ratchet WS Server on: 127.0.0.1:5555

这意味着 WebSocket 服务器现在已启动并运行!

从这里开始,只有 WebSocket 服务器正在运行!这并不意味着您可以订阅、发布或调用。请按照下一步操作:)

生产部署

如何在生产中运行您的 WebSocket 服务器?

app/console gos:websocket:server --env=prod 或 bin/console gos:websocket:server --env=prod

使用 supervisord 和其他内容示例将随后提供

对抗内存泄漏!

那么为什么我的内存不断增加呢?

在开发模式下这是正常的。(在这个环境中不要测试内存泄漏,永远不要)在您的命令中追加 --env=prod。您是否使用 fingers_crossed 处理器与 monolog?如果是,请切换到流。这是 fingers_crossed 预期行为。它将日志条目存储在内存中,直到 action_level 事件发生。此包的依赖项可能有些问题:(但是我也无能为力,如果发生这种情况,降级或冻结受影响的依赖项)这是您的责任:)深入您自己的代码。如何测试内存泄漏?

app/console gos:websocket:server --profile --env=prod 或 bin/console gos:websocket:server --profile --env=prod

并触发所有内容。

源代码

https://github.com/GeniusesOfSymfony/WebSocketBundle/blob/master/README.md