Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fre5h/centrifugobundle
đĻ Provides communication with web-socket server Centrifugo in Symfony applications.
https://github.com/fre5h/centrifugobundle
bundle centrifugo centrifugo-bundle real-time socket symfony web-socket websocket
Last synced: about 23 hours ago
JSON representation
đĻ Provides communication with web-socket server Centrifugo in Symfony applications.
- Host: GitHub
- URL: https://github.com/fre5h/centrifugobundle
- Owner: fre5h
- License: mit
- Created: 2019-01-09T09:47:23.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2024-07-03T19:53:27.000Z (7 months ago)
- Last Synced: 2024-08-07T10:23:08.529Z (6 months ago)
- Topics: bundle, centrifugo, centrifugo-bundle, real-time, socket, symfony, web-socket, websocket
- Language: PHP
- Homepage: https://centrifugal.github.io/centrifugo/
- Size: 1.66 MB
- Stars: 76
- Watchers: 4
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# CentrifugoBundle
đĻ Provides communication with web-socket server [Centrifugo](https://centrifugal.dev) in [Symfony](https://symfony.com) applications.
[![Scrutinizer Quality Score](https://img.shields.io/scrutinizer/g/fre5h/CentrifugoBundle.svg?style=flat-square)](https://scrutinizer-ci.com/g/fre5h/CentrifugoBundle/)
[![Build Status](https://img.shields.io/github/actions/workflow/status/fre5h/CentrifugoBundle/ci.yaml?branch=main&style=flat-square)](https://github.com/fre5h/CentrifugoBundle/actions?query=workflow%3ACI+branch%3Amain+)
[![CodeCov](https://img.shields.io/codecov/c/github/fre5h/CentrifugoBundle.svg?style=flat-square)](https://codecov.io/github/fre5h/CentrifugoBundle)
[![License](https://img.shields.io/packagist/l/fresh/centrifugo-bundle.svg?style=flat-square)](https://packagist.org/packages/fresh/centrifugo-bundle)
[![Latest Stable Version](https://img.shields.io/packagist/v/fresh/centrifugo-bundle.svg?style=flat-square)](https://packagist.org/packages/fresh/centrifugo-bundle)
[![Total Downloads](https://img.shields.io/packagist/dt/fresh/centrifugo-bundle.svg?style=flat-square)](https://packagist.org/packages/fresh/centrifugo-bundle)
[![StyleCI](https://styleci.io/repos/164834807/shield?style=flat-square)](https://styleci.io/repos/164834807)
[![Gitter](https://img.shields.io/badge/gitter-join%20chat-brightgreen.svg?style=flat-square)](https://gitter.im/fre5h/CentrifugoBundle)## Features đ
- [x] Compatible with latest [Centrifugo 5.4.7](https://github.com/centrifugal/centrifugo/releases/tag/v5.4.7) đ
- [x] Wrapper over [Centrifugo HTTP API](https://centrifugal.dev/docs/server/server_api#http-api) đ
- [X] Authentication with JWT token (HMAC algorithm) for [anonymous](./Resources/docs/authentication.md#anonymous), [authenticated user](./Resources/docs/authentication.md#authenticated-user) and [private channel](./Resources/docs/authentication.md#private-channel) đī¸
- [x] [Batch request](./Resources/docs/centrifugo_service_methods.md#batch-request) in [JSON streaming format](https://en.wikipedia.org/wiki/JSON_streaming) đĒ
- [x] [Console commands](./Resources/docs/console_commands.md "Console commands") âī¸ī¸
- [x] Integration into Symfony Web-Profiler đī¸## Requirements đ§
* PHP >= 8.3
* Symfony 7.0## Installation đą
```bash
$ composer req fresh/centrifugo-bundle
```##### Choose the version you need
| Bundle Version (X.Y.Z) | PHP | Symfony | Comment |
|:----------------------:|:--------:|:-------:|:--------------------|
| `6.2.*` | `>= 8.3` | `7.*` | **Current version** |
| `5.3.*` | `>= 8.2` | `7.*` | Previous version |By default, [Symfony Flex](https://symfony.com/doc/current/setup/flex.html) adds this bundle to the `config/bundles.php` file and adds required environment variables into `.env` file.
In case when you ignored `contrib-recipe` during bundle installation it would not be done. Then you have to do this manually.#### Check the `config/bundles.php` file
```php
# config/bundles.phpreturn [
// Other bundles...
Fresh\CentrifugoBundle\FreshCentrifugoBundle::class => ['all' => true],
// Other bundles...
];
```#### Check the `.env` file and add you configuration
```yaml
# .env###> fresh/centrifugo-bundle ###
CENTRIFUGO_API_KEY=secret-api-key
CENTRIFUGO_API_ENDPOINT=http://localhost:8000/api
CENTRIFUGO_SECRET=secret
###< fresh/centrifugo-bundle ###
````CENTRIFUGO_API_KEY` should be the same value as option `api_key` in your Centrifugo config file.
`CENTRIFUGO_SECRET` should be the same value as option `token_hmac_secret_key` in your Centrifugo config file.âšī¸ [Customize bundle configuration](./Resources/docs/configuration.md "Customize bundle configuration")
## Using đ§âđ
### Centrifugo service
```php
centrifugo->publish(['foo' => 'bar'], 'channelName');
}
}
```âšī¸ [More examples of using Centrifugo service](./Resources/docs/centrifugo_service_methods.md "More examples of using Centrifugo service")
### Authentication with JWT tokens đī¸
* [For anonymous](./Resources/docs/authentication.md#anonymous)
* [For authenticated User](./Resources/docs/authentication.md#authenticated-user)
* [For private channel](./Resources/docs/authentication.md#private-channel)### Console commands âī¸
* `centrifugo:publish`
* `centrifugo:broadcast`
* `centrifugo:subscribe`
* `centrifugo:unsubscribe`
* `centrifugo:disconnect`
* `centrifugo:refresh`
* `centrifugo:presence`
* `centrifugo:presence-stats`
* `centrifugo:history`
* `centrifugo:history-remove`
* `centrifugo:channels`
* `centrifugo:info`âšī¸ [More examples of using console commands](./Resources/docs/console_commands.md "More examples of using console commands")
### Integration into Symfony Web-Profiler đī¸
![](./Resources/images/profiler_example.png "Profiler example")
### Autocomplete channels in console commands đĒ
![](./Resources/images/autocomplete_example.gif)
## Contributing đ¤
Read the [CONTRIBUTING](https://github.com/fre5h/CentrifugoBundle/blob/master/.github/CONTRIBUTING.md) file.