WebSocketBundle

:part_alternation_mark: Symfony2 server side (Ratchet) & client websocket (Autobahn)

Github星跟踪图

GosWebSocketBundle

Latest Stable Version Latest Unstable Version Total Downloads License Build Status Scrutinizer Code Quality Code Coverage
Websocket

About

GosWebSocketBundle is a Symfony bundle designed to bring together websocket functionality in a easy to use application architecture.

Much like Socket.IO, it provides both a server and client implementation ensuring you have to write as little as possible to get your application up and running.

Powered By Ratchet and Autobahn JS, with Symfony

Demo project

Support
-------, Version, Status, Symfony Versions, Documentation, -------, ----------------------------, -------------------------, ------------------------------------------------------------------------------------------, 1.x, Bug Fixes Until July 1, 2020, 2.3-2.8, 3.0-3.4, 4.0-4.4, View Docs, 2.x, Actively Supported, 3.4, 4.4, 5.0, View Docs, 3.x, In Development, 4.4, 5.0, View Docs, What can I do with this bundle?

Websockets are very helpful for applications which require live activity and updates, including:

  • Chat applications
  • Real time notifications
  • Browser games

Built in features

  • PHP Websocket server (IO / WAMP)
  • PHP Websocket client (IO / WAMP)
  • JavaScript Websocket client (IO / WAMP)
  • PubSub Router
  • Remote Procedure Calls
  • User authentication
  • Periodic calls
  • Origin checker
  • Push (amqp)

Resources

Code Cookbook

Installation Instructions

Step 1: Install via Composer

If your application requires support for Symfony versions before 3.4, use the 1.x releases of this bundle. For Symfony 3.4 or newer, use the 2.x releases.

composer require gos/web-socket-bundle

Step 2: Enable the bundle

If your application is based on the Symfony Standard structure, you will need to add the bundle and its dependency, the GosPubSubRouterBundle, to your AppKernel class' registerBundles() method.

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            // ...

            new Gos\Bundle\PubSubRouterBundle\GosPubSubRouterBundle(),
            new Gos\Bundle\WebSocketBundle\GosWebSocketBundle(),
        ];

        // ...
    }

    // ...
}

If your application is based on the Symfony Flex structure, the bundle should be automatically registered, otherwise you will need to add it and its dependency, the GosPubSubRouterBundle, to your config/bundles.php file.

<?php

return [
    // ...

    Gos\Bundle\PubSubRouterBundle\GosPubSubRouterBundle::class => ['all' => true],
    Gos\Bundle\WebSocketBundle\GosWebSocketBundle::class => ['all' => true],
];

Step 3: Configure the bundle

The following is the minimum configuration necessary to use the bundle. If you are using the Symfony Standard structure, this will be added to your app/config/config.yml file. If you are using the Symfony Flex structure, this will be added to your config/packages/gos_web_socket.yaml file.

gos_web_socket:
    server:
        port: 8080        # The port the socket server will listen on
        host: 127.0.0.1   # The host ip to bind to

Step 4: Launching the server

With the bundle installed and configured, you can now launch the websocket server through your Symfony application's command-line console.

php bin/console gos:websocket:server

If everything is successful, you will see something similar to the following:

INFO      [websocket] Starting web socket
INFO      [websocket] Launching Ratchet on 127.0.0.1:8080 PID: 12345

Congratulations, your websocket server is now running. However, you will still need to add integrations to your application to fully use the bundle.

Original Project

https://github.com/JDare/ClankBundle

主要指标

概览
名称与所有者GeniusesOfSymfony/WebSocketBundle
主编程语言PHP
编程语言PHP (语言数: 3)
平台
许可证MIT License
所有者活动
创建于2015-02-08 23:58:21
推送于2023-01-04 01:22:17
最后一次提交
发布数98
最新版本名称v3.15.0 (发布于 2022-09-19 22:03:24)
第一版名称v1.0.0 (发布于 )
用户参与
星数613
关注者数22
派生数141
提交数1.1k
已启用问题?
问题数356
打开的问题数47
拉请求数94
打开的拉请求数2
关闭的拉请求数15
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?