Skip to content

Commit 0907fa1

Browse files
authored
feat(notifications): implement real-time notifications (#8)
* feat(notifications): implement real-time notifications - Configure Laravel Reverb WebSocket server for real-time communication - Set up Laravel Echo and Pusher JS for frontend WebSocket integration - Add broadcasting channels and authentication - Update development environment with WebSocket support * chore(notifications): add reverb config to lando yml * chore(notifications): move notification to the world plugin * feat(local): add prettier config file this file sets rules for VS code formatting * chore(notifications): remove pusher import from echo.js * chore(notifcations): remove installed pusher dependency * chore(notifications): move laravel-echo into dependency
1 parent d201339 commit 0907fa1

File tree

10 files changed

+378
-1
lines changed

10 files changed

+378
-1
lines changed

.lando.dist.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ services:
2929
ports:
3030
# Port forwarding for "npm run dev"
3131
- "3009:3009"
32+
- "8080:8080"
3233
appserver_nginx:
3334
scanner:
3435
path: /admin/login
@@ -53,6 +54,9 @@ services:
5354
proxy:
5455
pma:
5556
- pma.eclipse-app.lndo.site
57+
appserver:
58+
- ws.eclipse-app.lndo.site:8080
59+
5660
events:
5761
post-start:
5862
- sudo service supervisor start
@@ -69,3 +73,7 @@ tooling:
6973
cmd: "composer format"
7074
npm:
7175
service: appserver
76+
reverb:
77+
service: appserver
78+
description: Start Reverb WebSocket server
79+
cmd: "php artisan reverb:start --host=0.0.0.0 --port=8080"

.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"singleQuote": true,
3+
"semi": true,
4+
"trailingComma": "es5",
5+
"tabWidth": 2,
6+
"printWidth": 80,
7+
"bracketSpacing": true,
8+
"arrowParens": "avoid",
9+
"endOfLine": "lf"
10+
}

bootstrap/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
->withRouting(
1010
web: __DIR__.'/../routes/web.php',
1111
commands: __DIR__.'/../routes/console.php',
12+
channels: __DIR__.'/../routes/channels.php',
1213
health: '/up',
1314
)
1415
->withMiddleware(function (Middleware $middleware) {

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"php": "^8.3",
4343
"eclipsephp/core": "dev-main",
4444
"laravel/framework": "^11.31",
45+
"laravel/reverb": "^1.0",
4546
"laravel/tinker": "^2.9"
4647
},
4748
"require-dev": {

config/filament.php

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Broadcasting
8+
|--------------------------------------------------------------------------
9+
|
10+
| By uncommenting the Laravel Echo configuration, you may connect Filament
11+
| to any Pusher-compatible websockets server.
12+
|
13+
| This will allow your users to receive real-time notifications.
14+
|
15+
*/
16+
17+
'broadcasting' => [
18+
19+
'echo' => [
20+
'broadcaster' => 'reverb',
21+
'key' => env('VITE_REVERB_APP_KEY'),
22+
'secret' => env('VITE_REVERB_APP_SECRET'),
23+
'app_id' => env('VITE_REVERB_APP_ID'),
24+
'wsHost' => env('VITE_REVERB_HOST'),
25+
'wsPort' => env('VITE_REVERB_PORT', 8080),
26+
'wssPort' => env('VITE_REVERB_PORT', 8080),
27+
'authEndpoint' => '/broadcasting/auth',
28+
'disableStats' => true,
29+
'encrypted' => true,
30+
'forceTLS' => true,
31+
],
32+
33+
],
34+
35+
/*
36+
|--------------------------------------------------------------------------
37+
| Default Filesystem Disk
38+
|--------------------------------------------------------------------------
39+
|
40+
| This is the storage disk Filament will use to store files. You may use
41+
| any of the disks defined in the `config/filesystems.php`.
42+
|
43+
*/
44+
45+
'default_filesystem_disk' => env('FILAMENT_FILESYSTEM_DISK', 'public'),
46+
47+
/*
48+
|--------------------------------------------------------------------------
49+
| Assets Path
50+
|--------------------------------------------------------------------------
51+
|
52+
| This is the directory where Filament's assets will be published to. It
53+
| is relative to the `public` directory of your Laravel application.
54+
|
55+
| After changing the path, you should run `php artisan filament:assets`.
56+
|
57+
*/
58+
59+
'assets_path' => null,
60+
61+
/*
62+
|--------------------------------------------------------------------------
63+
| Cache Path
64+
|--------------------------------------------------------------------------
65+
|
66+
| This is the directory that Filament will use to store cache files that
67+
| are used to optimize the registration of components.
68+
|
69+
| After changing the path, you should run `php artisan filament:cache-components`.
70+
|
71+
*/
72+
73+
'cache_path' => base_path('bootstrap/cache/filament'),
74+
75+
/*
76+
|--------------------------------------------------------------------------
77+
| Livewire Loading Delay
78+
|--------------------------------------------------------------------------
79+
|
80+
| This sets the delay before loading indicators appear.
81+
|
82+
| Setting this to 'none' makes indicators appear immediately, which can be
83+
| desirable for high-latency connections. Setting it to 'default' applies
84+
| Livewire's standard 200ms delay.
85+
|
86+
*/
87+
88+
'livewire_loading_delay' => 'default',
89+
90+
/*
91+
|--------------------------------------------------------------------------
92+
| System Route Prefix
93+
|--------------------------------------------------------------------------
94+
|
95+
| This is the prefix used for the system routes that Filament registers,
96+
| such as the routes for downloading exports and failed import rows.
97+
|
98+
*/
99+
100+
'system_route_prefix' => 'filament',
101+
102+
];

config/reverb.php

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Default Reverb Server
8+
|--------------------------------------------------------------------------
9+
|
10+
| This option controls the default server used by Reverb to handle
11+
| incoming messages as well as broadcasting message to all your
12+
| connected clients. At this time only "reverb" is supported.
13+
|
14+
*/
15+
16+
'default' => env('REVERB_SERVER', 'reverb'),
17+
18+
/*
19+
|--------------------------------------------------------------------------
20+
| Reverb Servers
21+
|--------------------------------------------------------------------------
22+
|
23+
| Here you may define details for each of the supported Reverb servers.
24+
| Each server has its own configuration options that are defined in
25+
| the array below. You should ensure all the options are present.
26+
|
27+
*/
28+
29+
'servers' => [
30+
31+
'reverb' => [
32+
'host' => env('REVERB_SERVER_HOST', '0.0.0.0'),
33+
'port' => env('REVERB_SERVER_PORT', 8080),
34+
'path' => env('REVERB_SERVER_PATH', ''),
35+
'hostname' => env('REVERB_HOST'),
36+
'options' => [
37+
'tls' => [],
38+
],
39+
'max_request_size' => env('REVERB_MAX_REQUEST_SIZE', 10_000),
40+
'scaling' => [
41+
'enabled' => env('REVERB_SCALING_ENABLED', false),
42+
'channel' => env('REVERB_SCALING_CHANNEL', 'reverb'),
43+
'server' => [
44+
'url' => env('REDIS_URL'),
45+
'host' => env('REDIS_HOST', '127.0.0.1'),
46+
'port' => env('REDIS_PORT', '6379'),
47+
'username' => env('REDIS_USERNAME'),
48+
'password' => env('REDIS_PASSWORD'),
49+
'database' => env('REDIS_DB', '0'),
50+
'timeout' => env('REDIS_TIMEOUT', 60),
51+
],
52+
],
53+
'pulse_ingest_interval' => env('REVERB_PULSE_INGEST_INTERVAL', 15),
54+
'telescope_ingest_interval' => env('REVERB_TELESCOPE_INGEST_INTERVAL', 15),
55+
],
56+
57+
],
58+
59+
/*
60+
|--------------------------------------------------------------------------
61+
| Reverb Applications
62+
|--------------------------------------------------------------------------
63+
|
64+
| Here you may define how Reverb applications are managed. If you choose
65+
| to use the "config" provider, you may define an array of apps which
66+
| your server will support, including their connection credentials.
67+
|
68+
*/
69+
70+
'apps' => [
71+
72+
'provider' => 'config',
73+
74+
'apps' => [
75+
[
76+
'key' => env('REVERB_APP_KEY'),
77+
'secret' => env('REVERB_APP_SECRET'),
78+
'app_id' => env('REVERB_APP_ID'),
79+
'options' => [
80+
'host' => env('REVERB_HOST'),
81+
'port' => env('REVERB_PORT', 443),
82+
'scheme' => env('REVERB_SCHEME', 'https'),
83+
'useTLS' => env('REVERB_SCHEME', 'https') === 'https',
84+
],
85+
'allowed_origins' => ['*'],
86+
'ping_interval' => env('REVERB_APP_PING_INTERVAL', 60),
87+
'activity_timeout' => env('REVERB_APP_ACTIVITY_TIMEOUT', 30),
88+
'max_message_size' => env('REVERB_APP_MAX_MESSAGE_SIZE', 10_000),
89+
],
90+
],
91+
92+
],
93+
94+
];

0 commit comments

Comments
 (0)