Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit cc5e74e

Browse files
committed
Updated docs
1 parent 18dab98 commit cc5e74e

File tree

14 files changed

+48
-92
lines changed

14 files changed

+48
-92
lines changed

docs/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
packageName: Laravel Websockets
33
githubUrl: https://github.com/beyondcode/laravel-websockets
4-
---
4+
---

docs/advanced-usage/app-providers.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Depending on your setup, you might have your app configuration stored elsewhere
1111

1212
> Make sure that you do **not** perform any IO blocking tasks in your `AppManager`, as they will interfere with the asynchronous WebSocket execution.
1313
14-
In order to create your custom `AppManager`, create a class that implements the `BeyondCode\LaravelWebSockets\Apps\AppManager` interface.
14+
In order to create your custom `AppManager`, create a class that implements the `BeyondCode\LaravelWebSockets\Contracts\AppManager` interface.
1515

1616
This is what it looks like:
1717

@@ -34,11 +34,11 @@ interface AppManager
3434

3535
The following is an example AppManager that utilizes an Eloquent model:
3636
```php
37-
namespace App\Appmanagers;
37+
namespace App\Managers;
3838

3939
use App\Application;
4040
use BeyondCode\LaravelWebSockets\Apps\App;
41-
use BeyondCode\LaravelWebSockets\Apps\AppManager;
41+
use BeyondCode\LaravelWebSockets\Contracts\AppManager;
4242

4343
class MyCustomAppManager implements AppManager
4444
{
@@ -51,22 +51,22 @@ class MyCustomAppManager implements AppManager
5151
->toArray();
5252
}
5353

54-
public function findById($appId) : ? App
54+
public function findById($appId) : ?App
5555
{
5656
return $this->normalize(Application::findById($appId)->toArray());
5757
}
5858

59-
public function findByKey($appKey) : ? App
59+
public function findByKey($appKey) : ?App
6060
{
6161
return $this->normalize(Application::findByKey($appKey)->toArray());
6262
}
6363

64-
public function findBySecret($appSecret) : ? App
64+
public function findBySecret($appSecret) : ?App
6565
{
6666
return $this->normalize(Application::findBySecret($appSecret)->toArray());
6767
}
6868

69-
protected function normalize(?array $appAttributes) : ? App
69+
protected function normalize(?array $appAttributes) : ?App
7070
{
7171
if (! $appAttributes) {
7272
return null;
@@ -116,7 +116,5 @@ Once you have implemented your own AppManager, you need to set it in the `websoc
116116

117117
'app' => \App\Managers\MyCustomAppManager::class,
118118

119-
...
120-
121119
],
122120
```

docs/advanced-usage/custom-websocket-handlers.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ Once implemented, you will have a class that looks something like this:
1515
```php
1616
namespace App;
1717

18+
use Exception;
1819
use Ratchet\ConnectionInterface;
1920
use Ratchet\RFC6455\Messaging\MessageInterface;
2021
use Ratchet\WebSocket\MessageComponentInterface;
2122

2223
class MyCustomWebSocketHandler implements MessageComponentInterface
2324
{
24-
2525
public function onOpen(ConnectionInterface $connection)
2626
{
2727
// TODO: Implement onOpen() method.
@@ -32,7 +32,7 @@ class MyCustomWebSocketHandler implements MessageComponentInterface
3232
// TODO: Implement onClose() method.
3333
}
3434

35-
public function onError(ConnectionInterface $connection, \Exception $e)
35+
public function onError(ConnectionInterface $connection, Exception $e)
3636
{
3737
// TODO: Implement onError() method.
3838
}
@@ -48,12 +48,12 @@ In the class itself you have full control over all the lifecycle events of your
4848

4949
The only part missing is, that you will need to tell our WebSocket server to load this handler at a specific route endpoint. This can be achieved using the `WebSocketsRouter` facade.
5050

51-
This class takes care of registering the routes with the actual webSocket server. You can use the `webSocket` method to define a custom WebSocket endpoint. The method needs two arguments: the path where the WebSocket handled should be available and the fully qualified classname of the WebSocket handler class.
51+
This class takes care of registering the routes with the actual webSocket server. You can use the `get` method to define a custom WebSocket endpoint. The method needs two arguments: the path where the WebSocket handled should be available and the fully qualified classname of the WebSocket handler class.
5252

5353
This could, for example, be done inside your `routes/web.php` file.
5454

5555
```php
56-
WebSocketsRouter::webSocket('/my-websocket', \App\MyCustomWebSocketHandler::class);
56+
WebSocketsRouter::get('/my-websocket', \App\MyCustomWebSocketHandler::class);
5757
```
5858

5959
Once you've added the custom WebSocket route, be sure to restart our WebSocket server for the changes to take place.

docs/advanced-usage/events.md

Lines changed: 0 additions & 46 deletions
This file was deleted.

docs/advanced-usage/webhooks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class WebSocketHandler extends BaseWebSocketHandler
3636
// Run code on close.
3737
// $connection->app contains the app details
3838
// $this->channelManager is accessible
39-
}****
39+
}
4040
}
4141
```
4242

docs/basic-usage/pusher.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ To make it clear, the package does not restrict connections numbers or depend on
1313

1414
To make use of the Laravel WebSockets package in combination with Pusher, you first need to install the official Pusher PHP SDK.
1515

16-
If you are not yet familiar with the concept of Broadcasting in Laravel, please take a look at the [Laravel documentation](https://laravel.com/docs/6.0/broadcasting).
16+
If you are not yet familiar with the concept of Broadcasting in Laravel, please take a look at the [Laravel documentation](https://laravel.com/docs/8.0/broadcasting).
1717

1818
```bash
1919
composer require pusher/pusher-php-server "~4.0"
@@ -99,8 +99,8 @@ To enable or disable the statistics for one of your apps, you can modify the `en
9999

100100
## Usage with Laravel Echo
101101

102-
The Laravel WebSockets package integrates nicely into [Laravel Echo](https://laravel.com/docs/6.0/broadcasting#receiving-broadcasts) to integrate into your frontend application and receive broadcasted events.
103-
If you are new to Laravel Echo, be sure to take a look at the [official documentation](https://laravel.com/docs/6.0/broadcasting#receiving-broadcasts).
102+
The Laravel WebSockets package integrates nicely into [Laravel Echo](https://laravel.com/docs/8.0/broadcasting#receiving-broadcasts) to integrate into your frontend application and receive broadcasted events.
103+
If you are new to Laravel Echo, be sure to take a look at the [official documentation](https://laravel.com/docs/8.0/broadcasting#receiving-broadcasts).
104104

105105
To make Laravel Echo work with Laravel WebSockets, you need to make some minor configuration changes when working with Laravel Echo. Add the `wsHost` and `wsPort` parameters and point them to your Laravel WebSocket server host and port.
106106

@@ -111,7 +111,7 @@ When using Laravel WebSockets in combination with a custom SSL certificate, be s
111111
:::
112112

113113
```js
114-
import Echo from "laravel-echo"
114+
import Echo from 'laravel-echo';
115115

116116
window.Pusher = require('pusher-js');
117117

@@ -126,4 +126,4 @@ window.Echo = new Echo({
126126
});
127127
```
128128

129-
Now you can use all Laravel Echo features in combination with Laravel WebSockets, such as [Presence Channels](https://laravel.com/docs/7.x/broadcasting#presence-channels), [Notifications](https://laravel.com/docs/7.x/broadcasting#notifications) and [Client Events](https://laravel.com/docs/7.x/broadcasting#client-events).
129+
Now you can use all Laravel Echo features in combination with Laravel WebSockets, such as [Presence Channels](https://laravel.com/docs/8.x/broadcasting#presence-channels), [Notifications](https://laravel.com/docs/8.x/broadcasting#notifications) and [Client Events](https://laravel.com/docs/8.x/broadcasting#client-events).

docs/basic-usage/restarting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ order: 4
77

88
If you use Supervisor to keep your server alive, you might want to restart it just like `queue:restart` does.
99

10-
To do so, consider using the `websockets:restart`. In a maximum of 10 seconds, the server will be restarted automatically.
10+
To do so, consider using the `websockets:restart`. In a maximum of 10 seconds since issuing the command, the server will be restarted.
1111

1212
```bash
1313
php artisan websockets:restart

docs/basic-usage/ssl.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Since most of the web's traffic is going through HTTPS, it's also crucial to sec
1010
## Configuration
1111

1212
The SSL configuration takes place in your `config/websockets.php` file.
13+
1314
The default configuration has a SSL section that looks like this:
1415

1516
```php
@@ -31,6 +32,7 @@ The default configuration has a SSL section that looks like this:
3132
```
3233

3334
But this is only a subset of all the available configuration options.
35+
3436
This packages makes use of the official PHP [SSL context options](http://php.net/manual/en/context.ssl.php).
3537

3638
So if you find yourself in the need of adding additional configuration settings, take a look at the PHP documentation and simply add the configuration parameters that you need.

docs/debugging/dashboard.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,12 @@ protected function schedule(Schedule $schedule)
7171

7272
Each app contains an `enable_statistics` that defines wether that app generates statistics or not. The statistics are being stored for the `interval_in_seconds` seconds and then they are inserted in the database.
7373

74-
However, to disable it entirely and void any incoming statistic, you can change the statistics logger to `NullStatisticsLogger` under your current replication driver.
74+
However, to disable it entirely and void any incoming statistic, you can call `--disable-statistics` when running the server command:
7575

76-
```php
77-
// 'logger' => \BeyondCode\LaravelWebSockets\Statistics\Logger\MemoryStatisticsLogger::class,
78-
'statistics_logger' => \BeyondCode\LaravelWebSockets\Statistics\Logger\NullStatisticsLogger::class, // use the `NullStatisticsLogger` instead
76+
```bash
77+
php artisan websockets:serve --disable-statistics
7978
```
8079

81-
## Custom Statistics Drivers
82-
83-
By default, the package comes with a few drivers like the Database driver which stores the data into the database.
84-
85-
You should add your custom drivers under the `statistics` key in `websockets.php` and create a driver class that implements the `\BeyondCode\LaravelWebSockets\Statistics\Drivers\StatisticsDriver` interface.
86-
87-
Take a quick look at the `\BeyondCode\LaravelWebSockets\Statistics\Drivers\DatabaseDriver` driver to see how to perform your integration.
88-
8980
## Event Creator
9081

9182
The dashboard also comes with an easy-to-use event creator, that lets you manually send events to your channels.

docs/faq/scaling.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ Here is another benchmark that was run on a 2GB Digital Ocean droplet with 2 CPU
1616
![Benchmark](/img/simultaneous_users_2gb.png)
1717

1818
Make sure to take a look at the [Deployment Tips](/docs/laravel-websockets/faq/deploying) to find out how to improve your specific setup.
19+
20+
# Horizontal Scaling
21+
22+
When deploying to multi-node environments, you will notice that the server won't behave correctly. Check [Horizontal Scaling](../horizontal-scaling/getting-started.md) section.

docs/getting-started/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ php artisan vendor:publish --provider="BeyondCode\LaravelWebSockets\WebSocketsSe
2121

2222
# Statistics
2323

24-
This package comes with a migration to store statistic information while running your WebSocket server. For more info, check the [Debug Dashboard](../debugging/dashboard.md) section.
24+
This package comes with migrations to store statistic information while running your WebSocket server. For more info, check the [Debug Dashboard](../debugging/dashboard.md) section.
2525

2626
You can publish the migration file using:
2727

docs/getting-started/introduction.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ order: 1
44
---
55

66
# Laravel WebSockets 🛰
7+
78
WebSockets for Laravel. Done right.
89

9-
Laravel WebSockets is a package for Laravel 5.7 and up that will get your application started with WebSockets in no-time! It has a drop-in Pusher API replacement, has a debug dashboard, realtime statistics and even allows you to create custom WebSocket controllers.
10+
Laravel WebSockets is a package for Laravel that will get your application started with WebSockets in no-time! It has a drop-in Pusher API replacement, has a debug dashboard, realtime statistics and even allows you to create custom WebSocket controllers.
1011

1112
Once installed, you can start it with one simple command:
1213

@@ -18,4 +19,4 @@ php artisan websockets:serve
1819

1920
If you want to know how all of it works under the hood, we wrote an in-depth [blogpost](https://murze.be/introducing-laravel-websockets-an-easy-to-use-websocket-server-implemented-in-php) about it.
2021

21-
To help you get started, you can also take a look at the [demo repository](https://github.com/beyondcode/laravel-websockets-demo), that implements a basic Chat built with this package.
22+
To help you get started, you can also take a look at the [demo repository](https://github.com/beyondcode/laravel-websockets-demo), that implements a basic Chat built with this package.

docs/horizontal-scaling/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ For example, Redis does a great job by encapsulating the both the way of notifyi
1515

1616
## Configure the replication
1717

18-
To enable the replication, simply change the `replication.driver` name in the `websockets.php` file:
18+
To enable the replication, simply change the `replication.mode` name in the `websockets.php` file:
1919

2020
```php
2121
'replication' => [
2222

23-
'driver' => 'redis',
23+
'mode' => 'redis',
2424

2525
...
2626

docs/horizontal-scaling/redis.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
---
2-
title: Redis
2+
title: Redis Mode
33
order: 2
44
---
55

6-
## Configure the Redis driver
6+
# Redis Mode
77

8-
To enable the replication, simply change the `replication.driver` name in the `websockets.php` file to `redis`:
8+
Redis has the powerful ability to act both as a key-value store and as a PubSub service. This way, the connected servers will communicate between them whenever a message hits the server, so you can scale out to any amount of servers while preserving the WebSockets functionalities.
9+
10+
## Configure Redis mode
11+
12+
To enable the replication, simply change the `replication.mode` name in the `websockets.php` file to `redis`:
913

1014
```php
1115
'replication' => [
1216

13-
'driver' => 'redis',
17+
'mode' => 'redis',
1418

1519
...
1620

@@ -22,15 +26,17 @@ You can set the connection name to the Redis database under `redis`:
2226
```php
2327
'replication' => [
2428

25-
...
29+
'modes' =>
30+
31+
'redis' => [
2632

27-
'redis' => [
33+
'connection' => 'default',
2834

29-
'connection' => 'default',
35+
],
3036

3137
],
3238

3339
],
3440
```
3541

36-
The connections can be found in your `config/database.php` file, under the `redis` key. It defaults to connection `default`.
42+
The connections can be found in your `config/database.php` file, under the `redis` key.

0 commit comments

Comments
 (0)