diff --git a/.codecov.yml b/.codecov.yml
new file mode 100644
index 0000000000..33dbc6bf33
--- /dev/null
+++ b/.codecov.yml
@@ -0,0 +1,18 @@
+codecov:
+ notify:
+ require_ci_to_pass: yes
+
+coverage:
+ precision: 2
+ round: down
+ range: "70...100"
+
+status:
+ project: yes
+ patch: yes
+ changes: no
+
+comment:
+ layout: "reach, diff, flags, files, footer"
+ behavior: default
+ require_changes: no
diff --git a/.editorconfig b/.editorconfig
index cd8eb86efa..9718070fd3 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -11,5 +11,8 @@ end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
+[*.{blade.php,yml,yaml}]
+indent_size = 2
+
[*.md]
trim_trailing_whitespace = false
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000000..d9d2d331c9
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,81 @@
+name: CI
+
+on:
+ push:
+ branches:
+ - '*'
+ tags:
+ - '*'
+ pull_request:
+ branches:
+ - '*'
+
+jobs:
+ build:
+ if: "!contains(github.event.head_commit.message, 'skip ci')"
+
+ runs-on: ubuntu-latest
+
+ strategy:
+ fail-fast: false
+ matrix:
+ php:
+ - '8.0'
+ - '8.1'
+ laravel:
+ - 9.*
+ prefer:
+ - 'prefer-lowest'
+ - 'prefer-stable'
+ include:
+ - laravel: '9.*'
+ testbench: '7.*'
+
+ name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} --${{ matrix.prefer }}
+
+ steps:
+ - uses: actions/checkout@v1
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
+ coverage: pcov
+
+ - name: Setup MySQL
+ uses: haltuf/mysql-action@master
+ with:
+ mysql version: '8.0'
+ mysql database: 'websockets_test'
+ mysql root password: 'password'
+
+ - name: Setup Redis
+ uses: supercharge/redis-github-action@1.1.0
+ with:
+ redis-version: 6
+
+ - uses: actions/cache@v1
+ name: Cache dependencies
+ with:
+ path: ~/.composer/cache/files
+ key: composer-php-${{ matrix.php }}-${{ matrix.laravel }}-${{ matrix.prefer }}-${{ hashFiles('composer.json') }}
+
+ - name: Install dependencies
+ run: |
+ composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench-browser-kit:${{ matrix.testbench }}" "orchestra/database:${{ matrix.testbench }}" --no-interaction --no-update
+ composer update --${{ matrix.prefer }} --prefer-dist --no-interaction --no-suggest
+
+ - name: Run tests for Local
+ run: |
+ REPLICATION_MODE=local vendor/bin/phpunit --coverage-text --coverage-clover=coverage_local.xml
+
+ - name: Run tests for Redis
+ run: |
+ REPLICATION_MODE=redis vendor/bin/phpunit --coverage-text --coverage-clover=coverage_redis.xml
+
+ - uses: codecov/codecov-action@v1
+ with:
+ fail_ci_if_error: false
+ file: '*.xml'
+ token: ${{ secrets.CODECOV_TOKEN }}
diff --git a/.gitignore b/.gitignore
index 808f8c5b83..65e1146246 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,9 @@
+/vendor
+/.idea
build
+.phpunit.result.cache
+coverage
+composer.phar
composer.lock
-docs
-vendor
-coverage
\ No newline at end of file
+.DS_Store
+database.sqlite
diff --git a/.scrutinizer.yml b/.scrutinizer.yml
index df16b68b52..76733d0c94 100644
--- a/.scrutinizer.yml
+++ b/.scrutinizer.yml
@@ -1,19 +1,19 @@
filter:
- excluded_paths: [tests/*]
+ excluded_paths: [tests/*]
checks:
- php:
- remove_extra_empty_lines: true
- remove_php_closing_tag: true
- remove_trailing_whitespace: true
- fix_use_statements:
- remove_unused: true
- preserve_multiple: false
- preserve_blanklines: true
- order_alphabetically: true
- fix_php_opening_tag: true
- fix_linefeed: true
- fix_line_ending: true
- fix_identation_4spaces: true
- fix_doc_comments: true
+ php:
+ remove_extra_empty_lines: true
+ remove_php_closing_tag: true
+ remove_trailing_whitespace: true
+ fix_use_statements:
+ remove_unused: true
+ preserve_multiple: false
+ preserve_blanklines: true
+ order_alphabetically: true
+ fix_php_opening_tag: true
+ fix_linefeed: true
+ fix_line_ending: true
+ fix_identation_4spaces: true
+ fix_doc_comments: true
diff --git a/.styleci.yml b/.styleci.yml
index f4d3cbc61b..c3bb259c55 100644
--- a/.styleci.yml
+++ b/.styleci.yml
@@ -1,4 +1 @@
-preset: laravel
-
-disabled:
- - single_class_element_per_statement
+preset: laravel
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 24c2d6cb40..0000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-language: php
-
-php:
- - 7.1
- - 7.2
- - 7.3
-
-env:
- matrix:
- - COMPOSER_FLAGS="--prefer-lowest"
- - COMPOSER_FLAGS=""
-
-before_script:
- - travis_retry composer self-update
- - travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source
-
-script:
- - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
-
-after_script:
- - php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover
diff --git a/CHANGELOG.md b/CHANGELOG.md
deleted file mode 100644
index 2338172661..0000000000
--- a/CHANGELOG.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# Changelog
-
-All notable changes to `laravel-websockets` will be documented in this file
-
-## 1.0.2 - 2018-12-06
-
-- Fix issue with wrong namespaces
-
-## 1.0.1 - 2018-12-04
-
-- Remove VueJS debug mode on dashboard
-- Allow setting app hosts to use when connecting via the dashboard
-- Added debug mode when starting the WebSocket server
-
-## 1.0.0 - 2018-12-04
-
-- initial release
diff --git a/LICENSE.md b/LICENSE
similarity index 100%
rename from LICENSE.md
rename to LICENSE
diff --git a/README.md b/README.md
index cc2c0e0a33..06d9636ff1 100644
--- a/README.md
+++ b/README.md
@@ -1,19 +1,20 @@
# Laravel WebSockets 🛰
+> [!NOTE]
+> Laravel WebSockets is no longer maintained. If you are looking for a PHP-based WebSocket solution, check out [Laravel Reverb](https://reverb.laravel.com) which is also built on top of ReactPHP and allows you to horizontally scale the WebSocket server.
+
[](https://packagist.org/packages/beyondcode/laravel-websockets)
-[](https://travis-ci.org/beyondcode/laravel-websockets)
+
[](https://scrutinizer-ci.com/g/beyondcode/laravel-websockets)
[](https://packagist.org/packages/beyondcode/laravel-websockets)
Bring the power of WebSockets to your Laravel application. Drop-in Pusher replacement, SSL support, Laravel Echo support and a debug dashboard are just some of its features.
-[](https://phppackagedevelopment.com)
-
-If you want to learn how to create reusable PHP packages yourself, take a look at my upcoming [PHP Package Development](https://phppackagedevelopment.com) video course.
+[](https://tinkerwell.app/?ref=github)
## Documentation
-For installation instructions, in-depth usage and deployment details, please take a look at the [official documentation](https://docs.beyondco.de/laravel-websockets/).
+For installation instructions, in-depth usage and deployment details, please take a look at the [official documentation](https://beyondco.de/docs/laravel-websockets/getting-started/introduction/).
### Changelog
diff --git a/composer.json b/composer.json
index 028678adcf..e0760ca84d 100644
--- a/composer.json
+++ b/composer.json
@@ -1,12 +1,14 @@
{
"name": "beyondcode/laravel-websockets",
- "description": "An easy to use WebSocket server",
+ "description": "An easy to launch a Pusher-compatible WebSockets server for Laravel.",
"keywords": [
"beyondcode",
- "laravel-websockets"
+ "laravel-websockets",
+ "laravel",
+ "php"
],
- "homepage": "https://github.com/beyondcode/laravel-websockets",
"license": "MIT",
+ "homepage": "https://github.com/beyondcode/laravel-websockets",
"authors": [
{
"name": "Marcel Pociot",
@@ -19,46 +21,64 @@
"email": "freek@spatie.be",
"homepage": "https://spatie.be/",
"role": "Developer"
+ },
+ {
+ "name": "Alex Renoki",
+ "homepage": "https://github.com/rennokki",
+ "role": "Developer"
}
],
"require": {
- "php": "^7.1",
- "ext-json": "*",
- "cboden/ratchet": "^0.4.1",
- "clue/buzz-react": "^2.5",
+ "php": "^8.0|^8.1",
+ "cboden/ratchet": "^0.4.4",
+ "clue/block-react": "^1.5",
+ "clue/reactphp-sqlite": "^1.0",
+ "clue/redis-react": "^2.6",
+ "doctrine/dbal": "^2.9",
+ "evenement/evenement": "^2.0|^3.0",
+ "facade/ignition-contracts": "^1.0",
"guzzlehttp/psr7": "^1.5",
- "illuminate/broadcasting": "5.7.* || 5.8.*",
- "illuminate/console": "5.7.* || 5.8.*",
- "illuminate/http": "5.7.* || 5.8.*",
- "illuminate/routing": "5.7.* || 5.8.*",
- "illuminate/support": "5.7.* || 5.8.*",
- "pusher/pusher-php-server": "~3.0",
- "symfony/http-kernel": "~4.0",
- "symfony/psr-http-message-bridge": "^1.1"
+ "illuminate/broadcasting": "^9.0",
+ "illuminate/console": "^9.0",
+ "illuminate/http": "^9.0",
+ "illuminate/queue": "^9.0",
+ "illuminate/routing": "^9.0",
+ "illuminate/support": "^9.0",
+ "pusher/pusher-php-server": "^6.0|^7.0",
+ "react/mysql": "^0.5",
+ "react/promise": "^2.8",
+ "symfony/http-kernel": "^5.0|^6.0",
+ "symfony/psr-http-message-bridge": "^1.1|^2.0"
},
"require-dev": {
- "mockery/mockery": "^1.2",
- "orchestra/testbench": "3.7.* || 3.8.*",
- "phpunit/phpunit": "^7.0"
+ "clue/buzz-react": "^2.9",
+ "laravel/legacy-factories": "^1.1",
+ "orchestra/testbench-browser-kit": "^7.0",
+ "phpunit/phpunit": "^9.0",
+ "ratchet/pawl": "^0.3.5"
+ },
+ "suggest": {
+ "ext-pcntl": "Running the server needs pcntl to listen to command signals and soft-shutdown.",
+ "doctrine/dbal": "Required to run database migrations (^2.9|^3.0)."
},
"autoload": {
"psr-4": {
- "BeyondCode\\LaravelWebSockets\\": "src"
+ "BeyondCode\\LaravelWebSockets\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
- "BeyondCode\\LaravelWebSockets\\Tests\\": "tests"
+ "BeyondCode\\LaravelWebSockets\\Test\\": "tests"
}
},
"scripts": {
- "test": "vendor/bin/phpunit",
- "test-coverage": "vendor/bin/phpunit --coverage-html coverage"
-
+ "test": "vendor/bin/phpunit"
},
"config": {
"sort-packages": true
},
+ "minimum-stability": "dev",
+ "prefer-stable": true,
"extra": {
"laravel": {
"providers": [
diff --git a/config/websockets.php b/config/websockets.php
index cf465453ab..a321ace98b 100644
--- a/config/websockets.php
+++ b/config/websockets.php
@@ -1,127 +1,326 @@
[
+
+ 'port' => env('LARAVEL_WEBSOCKETS_PORT', 6001),
+
+ 'domain' => env('LARAVEL_WEBSOCKETS_DOMAIN'),
+
+ 'path' => env('LARAVEL_WEBSOCKETS_PATH', 'laravel-websockets'),
+
+ 'middleware' => [
+ 'web',
+ \BeyondCode\LaravelWebSockets\Dashboard\Http\Middleware\Authorize::class,
+ ],
+
+ ],
+
+ 'managers' => [
+
+ /*
+ |--------------------------------------------------------------------------
+ | Application Manager
+ |--------------------------------------------------------------------------
+ |
+ | An Application manager determines how your websocket server allows
+ | the use of the TCP protocol based on, for example, a list of allowed
+ | applications.
+ | By default, it uses the defined array in the config file, but you can
+ | choose to use SQLite or MySQL application managers, or define a
+ | custom application manager.
+ |
+ */
+
+ 'app' => \BeyondCode\LaravelWebSockets\Apps\ConfigAppManager::class,
+
+ /*
+ |--------------------------------------------------------------------------
+ | SQLite application manager
+ |--------------------------------------------------------------------------
+ |
+ | The SQLite database to use when using the SQLite application manager.
+ |
+ */
+
+ 'sqlite' => [
+ 'database' => storage_path('laravel-websockets.sqlite'),
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | MySql application manager
+ |--------------------------------------------------------------------------
+ |
+ | The MySQL database connection to use.
+ |
+ */
+
+ 'mysql' => [
+ 'connection' => env('DB_CONNECTION', 'mysql'),
+
+ 'table' => 'websockets_apps',
+ ],
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Applications Repository
+ |--------------------------------------------------------------------------
+ |
+ | By default, the only allowed app is the one you define with
+ | your PUSHER_* variables from .env.
+ | You can configure to use multiple apps if you need to, or use
+ | a custom App Manager that will handle the apps from a database, per se.
+ |
+ | You can apply multiple settings, like the maximum capacity, enable
+ | client-to-client messages or statistics.
+ |
+ */
+
'apps' => [
[
'id' => env('PUSHER_APP_ID'),
'name' => env('APP_NAME'),
+ 'host' => env('PUSHER_APP_HOST'),
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
+ 'path' => env('PUSHER_APP_PATH'),
'capacity' => null,
'enable_client_messages' => false,
'enable_statistics' => true,
+ 'allowed_origins' => [
+ // env('LARAVEL_WEBSOCKETS_DOMAIN'),
+ ],
],
],
/*
- * This class is responsible for finding the apps. The default provider
- * will use the apps defined in this config file.
- *
- * You can create a custom provider by implementing the
- * `AppProvider` interface.
- */
- 'app_provider' => BeyondCode\LaravelWebSockets\Apps\ConfigAppProvider::class,
+ |--------------------------------------------------------------------------
+ | Broadcasting Replication PubSub
+ |--------------------------------------------------------------------------
+ |
+ | You can enable replication to publish and subscribe to
+ | messages across the driver.
+ |
+ | By default, it is set to 'local', but you can configure it to use drivers
+ | like Redis to ensure connection between multiple instances of
+ | WebSocket servers. Just set the driver to 'redis' to enable the PubSub using Redis.
+ |
+ */
- /*
- * This array contains the hosts of which you want to allow incoming requests.
- * Leave this empty if you want to accept requests from all hosts.
- */
- 'allowed_origins' => [
- //
- ],
+ 'replication' => [
- /*
- * The maximum request size in kilobytes that is allowed for an incoming WebSocket request.
- */
- 'max_request_size_in_kb' => 250,
+ 'mode' => env('WEBSOCKETS_REPLICATION_MODE', 'local'),
- /*
- * This path will be used to register the necessary routes for the package.
- */
- 'path' => 'laravel-websockets',
+ 'modes' => [
+
+ /*
+ |--------------------------------------------------------------------------
+ | Local Replication
+ |--------------------------------------------------------------------------
+ |
+ | Local replication is actually a null replicator, meaning that it
+ | is the default behaviour of storing the connections into an array.
+ |
+ */
+
+ 'local' => [
+
+ /*
+ |--------------------------------------------------------------------------
+ | Channel Manager
+ |--------------------------------------------------------------------------
+ |
+ | The channel manager is responsible for storing, tracking and retrieving
+ | the channels as long as their members and connections.
+ |
+ */
+
+ 'channel_manager' => \BeyondCode\LaravelWebSockets\ChannelManagers\LocalChannelManager::class,
+
+ /*
+ |--------------------------------------------------------------------------
+ | Statistics Collector
+ |--------------------------------------------------------------------------
+ |
+ | The Statistics Collector will, by default, handle the incoming statistics,
+ | storing them until they will become dumped into another database, usually
+ | a MySQL database or a time-series database.
+ |
+ */
+
+ 'collector' => \BeyondCode\LaravelWebSockets\Statistics\Collectors\MemoryCollector::class,
+
+ ],
+
+ 'redis' => [
+
+ 'connection' => env('WEBSOCKETS_REDIS_REPLICATION_CONNECTION', 'default'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Channel Manager
+ |--------------------------------------------------------------------------
+ |
+ | The channel manager is responsible for storing, tracking and retrieving
+ | the channels as long as their members and connections.
+ |
+ */
+
+ 'channel_manager' => \BeyondCode\LaravelWebSockets\ChannelManagers\RedisChannelManager::class,
+
+ /*
+ |--------------------------------------------------------------------------
+ | Statistics Collector
+ |--------------------------------------------------------------------------
+ |
+ | The Statistics Collector will, by default, handle the incoming statistics,
+ | storing them until they will become dumped into another database, usually
+ | a MySQL database or a time-series database.
+ |
+ */
+
+ 'collector' => \BeyondCode\LaravelWebSockets\Statistics\Collectors\RedisCollector::class,
+
+ ],
+
+ ],
- /*
- * Dashboard Routes Middleware
- *
- * These middleware will be assigned to every dashboard route, giving you
- * the chance to add your own middleware to this list or change any of
- * the existing middleware. Or, you can simply stick with this list.
- */
- 'middleware' => [
- 'web',
- Authorize::class,
],
'statistics' => [
+
/*
- * This model will be used to store the statistics of the WebSocketsServer.
- * The only requirement is that the model should extend
- * `WebSocketsStatisticsEntry` provided by this package.
- */
- 'model' => \BeyondCode\LaravelWebSockets\Statistics\Models\WebSocketsStatisticsEntry::class,
+ |--------------------------------------------------------------------------
+ | Statistics Store
+ |--------------------------------------------------------------------------
+ |
+ | The Statistics Store is the place where all the temporary stats will
+ | be dumped. This is a much reliable store and will be used to display
+ | graphs or handle it later on your app.
+ |
+ */
+
+ 'store' => \BeyondCode\LaravelWebSockets\Statistics\Stores\DatabaseStore::class,
/*
- * Here you can specify the interval in seconds at which statistics should be logged.
- */
+ |--------------------------------------------------------------------------
+ | Statistics Interval Period
+ |--------------------------------------------------------------------------
+ |
+ | Here you can specify the interval in seconds at which
+ | statistics should be logged.
+ |
+ */
+
'interval_in_seconds' => 60,
/*
- * When the clean-command is executed, all recorded statistics older than
- * the number of days specified here will be deleted.
- */
+ |--------------------------------------------------------------------------
+ | Statistics Deletion Period
+ |--------------------------------------------------------------------------
+ |
+ | When the clean-command is executed, all recorded statistics older than
+ | the number of days specified here will be deleted.
+ |
+ */
+
'delete_statistics_older_than_days' => 60,
- /*
- * Use an DNS resolver to make the requests to the statistics logger
- * default is to resolve everything to 127.0.0.1.
- */
- 'perform_dns_lookup' => false,
],
/*
- * Define the optional SSL context for your WebSocket connections.
- * You can see all available options at: http://php.net/manual/en/context.ssl.php
- */
+ |--------------------------------------------------------------------------
+ | Maximum Request Size
+ |--------------------------------------------------------------------------
+ |
+ | The maximum request size in kilobytes that is allowed for
+ | an incoming WebSocket request.
+ |
+ */
+
+ 'max_request_size_in_kb' => 250,
+
+ /*
+ |--------------------------------------------------------------------------
+ | SSL Configuration
+ |--------------------------------------------------------------------------
+ |
+ | By default, the configuration allows only on HTTP. For SSL, you need
+ | to set up the the certificate, the key, and optionally, the passphrase
+ | for the private key.
+ | You will need to restart the server for the settings to take place.
+ |
+ */
+
'ssl' => [
- /*
- * Path to local certificate file on filesystem. It must be a PEM encoded file which
- * contains your certificate and private key. It can optionally contain the
- * certificate chain of issuers. The private key also may be contained
- * in a separate file specified by local_pk.
- */
+
'local_cert' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT', null),
- /*
- * Path to local private key file on filesystem in case of separate files for
- * certificate (local_cert) and private key.
- */
+ 'capath' => env('LARAVEL_WEBSOCKETS_SSL_CA', null),
+
'local_pk' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_PK', null),
- /*
- * Passphrase for your local_cert file.
- */
'passphrase' => env('LARAVEL_WEBSOCKETS_SSL_PASSPHRASE', null),
+
+ 'verify_peer' => env('APP_ENV') === 'production',
+
+ 'allow_self_signed' => env('APP_ENV') !== 'production',
+
],
/*
- * Channel Manager
- * This class handles how channel persistence is handled.
- * By default, persistence is stored in an array by the running webserver.
- * The only requirement is that the class should implement
- * `ChannelManager` interface provided by this package.
- */
- 'channel_manager' => \BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManagers\ArrayChannelManager::class,
+ |--------------------------------------------------------------------------
+ | Route Handlers
+ |--------------------------------------------------------------------------
+ |
+ | Here you can specify the route handlers that will take over
+ | the incoming/outgoing websocket connections. You can extend the
+ | original class and implement your own logic, alongside
+ | with the existing logic.
+ |
+ */
+
+ 'handlers' => [
+
+ 'websocket' => \BeyondCode\LaravelWebSockets\Server\WebSocketHandler::class,
+
+ 'health' => \BeyondCode\LaravelWebSockets\Server\HealthHandler::class,
+
+ 'trigger_event' => \BeyondCode\LaravelWebSockets\API\TriggerEvent::class,
+
+ 'fetch_channels' => \BeyondCode\LaravelWebSockets\API\FetchChannels::class,
+
+ 'fetch_channel' => \BeyondCode\LaravelWebSockets\API\FetchChannel::class,
+
+ 'fetch_users' => \BeyondCode\LaravelWebSockets\API\FetchUsers::class,
+
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Promise Resolver
+ |--------------------------------------------------------------------------
+ |
+ | The promise resolver is a class that takes a input value and is
+ | able to make sure the PHP code runs async by using ->then(). You can
+ | use your own Promise Resolver. This is usually changed when you want to
+ | intercept values by the promises throughout the app, like in testing
+ | to switch from async to sync.
+ |
+ */
+
+ 'promise_resolver' => \React\Promise\FulfilledPromise::class,
+
];
diff --git a/database/migrations/0000_00_00_000000_create_websockets_apps_table.php b/database/migrations/0000_00_00_000000_create_websockets_apps_table.php
new file mode 100644
index 0000000000..7c22401fd9
--- /dev/null
+++ b/database/migrations/0000_00_00_000000_create_websockets_apps_table.php
@@ -0,0 +1,40 @@
+string('id')->index();
+ $table->string('key');
+ $table->string('secret');
+ $table->string('name');
+ $table->string('host')->nullable();
+ $table->string('path')->nullable();
+ $table->boolean('enable_client_messages')->default(false);
+ $table->boolean('enable_statistics')->default(true);
+ $table->unsignedInteger('capacity')->nullable();
+ $table->string('allowed_origins');
+ $table->nullableTimestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('websockets_apps');
+ }
+}
diff --git a/database/migrations/create_websockets_statistics_entries_table.php.stub b/database/migrations/0000_00_00_000000_create_websockets_statistics_entries_table.php
similarity index 74%
rename from database/migrations/create_websockets_statistics_entries_table.php.stub
rename to database/migrations/0000_00_00_000000_create_websockets_statistics_entries_table.php
index b56e525b3e..0989f288c5 100644
--- a/database/migrations/create_websockets_statistics_entries_table.php.stub
+++ b/database/migrations/0000_00_00_000000_create_websockets_statistics_entries_table.php
@@ -1,27 +1,32 @@
increments('id');
$table->string('app_id');
- $table->integer('peak_connection_count');
- $table->integer('websocket_message_count');
- $table->integer('api_message_count');
+ $table->integer('peak_connections_count');
+ $table->integer('websocket_messages_count');
+ $table->integer('api_messages_count');
$table->nullableTimestamps();
});
}
+
/**
* Reverse the migrations.
+ *
+ * @return void
*/
public function down()
{
diff --git a/database/migrations/sqlite/0000_00_00_000000_create_apps_table.sql b/database/migrations/sqlite/0000_00_00_000000_create_apps_table.sql
new file mode 100644
index 0000000000..c85f01a223
--- /dev/null
+++ b/database/migrations/sqlite/0000_00_00_000000_create_apps_table.sql
@@ -0,0 +1,12 @@
+CREATE TABLE IF NOT EXISTS apps (
+ id STRING NOT NULL,
+ key STRING NOT NULL,
+ secret STRING NOT NULL,
+ name STRING NOT NULL,
+ host STRING NULLABLE,
+ path STRING NULLABLE,
+ enable_client_messages BOOLEAN DEFAULT 0,
+ enable_statistics BOOLEAN DEFAULT 1,
+ capacity INTEGER NULLABLE,
+ allowed_origins STRING NULLABLE
+)
diff --git a/docs/_index.md b/docs/_index.md
new file mode 100644
index 0000000000..7c504e5514
--- /dev/null
+++ b/docs/_index.md
@@ -0,0 +1,4 @@
+---
+packageName: Laravel Websockets
+githubUrl: https://github.com/beyondcode/laravel-websockets
+---
diff --git a/docs/advanced-usage/_index.md b/docs/advanced-usage/_index.md
new file mode 100644
index 0000000000..0297feb27a
--- /dev/null
+++ b/docs/advanced-usage/_index.md
@@ -0,0 +1,4 @@
+---
+title: Advanced Usage
+order: 4
+---
diff --git a/docs/advanced-usage/app-providers.md b/docs/advanced-usage/app-providers.md
new file mode 100644
index 0000000000..77f4502144
--- /dev/null
+++ b/docs/advanced-usage/app-providers.md
@@ -0,0 +1,120 @@
+---
+title: Custom App Managers
+order: 1
+---
+
+# Custom App Managers
+
+With the multi-tenancy support of Laravel WebSockets, the default way of storing and retrieving the apps is by using the `websockets.php` config file.
+
+Depending on your setup, you might have your app configuration stored elsewhere and having to keep the configuration in sync with your app storage can be tedious. To simplify this, you can create your own `AppManager` class that will take care of retrieving the WebSocket credentials for a specific WebSocket application.
+
+> Make sure that you do **not** perform any IO blocking tasks in your `AppManager`, as they will interfere with the asynchronous WebSocket execution.
+
+In order to create your custom `AppManager`, create a class that implements the `BeyondCode\LaravelWebSockets\Contracts\AppManager` interface.
+
+This is what it looks like:
+
+```php
+interface AppManager
+{
+ /** @return array[BeyondCode\LaravelWebSockets\Apps\App] */
+ public function all(): array;
+
+ /** @return BeyondCode\LaravelWebSockets\Apps\App */
+ public function findById($appId): ?App;
+
+ /** @return BeyondCode\LaravelWebSockets\Apps\App */
+ public function findByKey($appKey): ?App;
+
+ /** @return BeyondCode\LaravelWebSockets\Apps\App */
+ public function findBySecret($appSecret): ?App;
+}
+```
+
+The following is an example AppManager that utilizes an Eloquent model:
+```php
+namespace App\Managers;
+
+use App\Application;
+use BeyondCode\LaravelWebSockets\Apps\App;
+use BeyondCode\LaravelWebSockets\Contracts\AppManager;
+
+class MyCustomAppManager implements AppManager
+{
+ public function all() : array
+ {
+ return Application::all()
+ ->map(function($app) {
+ return $this->normalize($app->toArray());
+ })
+ ->toArray();
+ }
+
+ public function findById($appId) : ?App
+ {
+ return $this->normalize(Application::findById($appId)->toArray());
+ }
+
+ public function findByKey($appKey) : ?App
+ {
+ return $this->normalize(Application::findByKey($appKey)->toArray());
+ }
+
+ public function findBySecret($appSecret) : ?App
+ {
+ return $this->normalize(Application::findBySecret($appSecret)->toArray());
+ }
+
+ protected function normalize(?array $appAttributes) : ?App
+ {
+ if (! $appAttributes) {
+ return null;
+ }
+
+ $app = new App(
+ $appAttributes['id'],
+ $appAttributes['key'],
+ $appAttributes['secret']
+ );
+
+ if (isset($appAttributes['name'])) {
+ $app->setName($appAttributes['name']);
+ }
+
+ if (isset($appAttributes['host'])) {
+ $app->setHost($appAttributes['host']);
+ }
+
+ $app
+ ->enableClientMessages($appAttributes['enable_client_messages'])
+ ->enableStatistics($appAttributes['enable_statistics']);
+
+ return $app;
+ }
+}
+```
+
+Once you have implemented your own AppManager, you need to set it in the `websockets.php` configuration file:
+
+```php
+'managers' => [
+
+ /*
+ |--------------------------------------------------------------------------
+ | Application Manager
+ |--------------------------------------------------------------------------
+ |
+ | An Application manager determines how your websocket server allows
+ | the use of the TCP protocol based on, for example, a list of allowed
+ | applications.
+ | By default, it uses the defined array in the config file, but you can
+ | anytime implement the same interface as the class and add your own
+ | custom method to retrieve the apps.
+ |
+ */
+
+ 'app' => \App\Managers\MyCustomAppManager::class,
+
+],
+```
diff --git a/docs/advanced-usage/custom-websocket-handlers.md b/docs/advanced-usage/custom-websocket-handlers.md
new file mode 100644
index 0000000000..e41ed628a7
--- /dev/null
+++ b/docs/advanced-usage/custom-websocket-handlers.md
@@ -0,0 +1,59 @@
+---
+title: Custom WebSocket Handlers
+order: 2
+---
+
+# Custom WebSocket Handlers
+
+While this package's main purpose is to make the usage of either the Pusher JavaScript client or Laravel Echo as easy as possible, you are not limited to the Pusher protocol at all.
+There might be situations where all you need is a simple, bare-bone, WebSocket server where you want to have full control over the incoming payload and what you want to do with it - without having "channels" in the way.
+
+You can easily create your own custom WebSocketHandler class. All you need to do is implement Ratchets `Ratchet\WebSocket\MessageComponentInterface`.
+
+Once implemented, you will have a class that looks something like this:
+
+```php
+namespace App;
+
+use Exception;
+use Ratchet\ConnectionInterface;
+use Ratchet\RFC6455\Messaging\MessageInterface;
+use Ratchet\WebSocket\MessageComponentInterface;
+
+class MyCustomWebSocketHandler implements MessageComponentInterface
+{
+ public function onOpen(ConnectionInterface $connection)
+ {
+ // TODO: Implement onOpen() method.
+ }
+
+ public function onClose(ConnectionInterface $connection)
+ {
+ // TODO: Implement onClose() method.
+ }
+
+ public function onError(ConnectionInterface $connection, Exception $e)
+ {
+ // TODO: Implement onError() method.
+ }
+
+ public function onMessage(ConnectionInterface $connection, MessageInterface $msg)
+ {
+ // TODO: Implement onMessage() method.
+ }
+}
+```
+
+In the class itself you have full control over all the lifecycle events of your WebSocket connections and can intercept the incoming messages and react to them.
+
+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.
+
+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.
+
+This could, for example, be done inside your `routes/web.php` file.
+
+```php
+WebSocketsRouter::addCustomRoute('GET', '/my-websocket', \App\MyCustomWebSocketHandler::class);
+```
+
+Once you've added the custom WebSocket route, be sure to restart our WebSocket server for the changes to take place.
diff --git a/docs/advanced-usage/dispatched-events.md b/docs/advanced-usage/dispatched-events.md
new file mode 100644
index 0000000000..be5e095b24
--- /dev/null
+++ b/docs/advanced-usage/dispatched-events.md
@@ -0,0 +1,82 @@
+---
+title: Dispatched Events
+order: 5
+---
+
+# Dispatched Events
+
+Laravel WebSockets takes advantage of Laravel's Event dispatching observer, in a way that you can handle in-server events outside of it.
+
+For example, you can listen for events like when a new connection establishes or when an user joins a presence channel.
+
+## Events
+
+Below you will find a list of dispatched events:
+
+- `BeyondCode\LaravelWebSockets\Events\NewConnection` - when a connection successfully establishes on the server
+- `BeyondCode\LaravelWebSockets\Events\ConnectionClosed` - when a connection leaves the server
+- `BeyondCode\LaravelWebSockets\Events\SubscribedToChannel` - when a connection subscribes to a specific channel
+- `BeyondCode\LaravelWebSockets\Events\UnsubscribedFromChannel` - when a connection unsubscribes from a specific channel
+- `BeyondCode\LaravelWebSockets\Events\WebSocketMessageReceived` - when the server receives a message
+- `BeyondCode\LaravelWebSockets\EventsConnectionPonged` - when a connection pings to the server that it is still alive
+
+## Queued Listeners
+
+Because the default Redis connection (either PhpRedis or Predis) is a blocking I/O method and can cause problems with the server speed and availability, you might want to check the [Non-Blocking Queue Driver](non-blocking-queue-driver.md) documentation that helps you create the Async Redis queue driver that is going to fix the Blocking I/O issue.
+
+If set up, you can use the `async-redis` queue driver in your listeners:
+
+```php
+ [
+ App\Listeners\HandleNewConnections::class,
+ ],
+];
+```
diff --git a/docs/advanced-usage/non-blocking-queue-driver.md b/docs/advanced-usage/non-blocking-queue-driver.md
new file mode 100644
index 0000000000..98ed10d1a8
--- /dev/null
+++ b/docs/advanced-usage/non-blocking-queue-driver.md
@@ -0,0 +1,30 @@
+---
+title: Non-Blocking Queue Driver
+order: 4
+---
+
+# Non-Blocking Queue Driver
+
+In Laravel, he default Redis connection also interacts with the queues. Since you might want to dispatch jobs on Redis from the server, you can encounter an anti-pattern of using a blocking I/O connection (like PhpRedis or PRedis) within the WebSockets server.
+
+To solve this issue, you can configure the built-in queue driver that uses the Async Redis connection when it's possible, like within the WebSockets server. It's highly recommended to switch your queue to it if you are going to use the queues within the server controllers, for example.
+
+Add the `async-redis` queue driver to your list of connections. The configuration parameters are compatible with the default `redis` driver:
+
+```php
+'connections' => [
+ 'async-redis' => [
+ 'driver' => 'async-redis',
+ 'connection' => env('WEBSOCKETS_REDIS_REPLICATION_CONNECTION', 'default'),
+ 'queue' => env('REDIS_QUEUE', 'default'),
+ 'retry_after' => 90,
+ 'block_for' => null,
+ ],
+]
+```
+
+Also, make sure that the default queue driver is set to `async-redis`:
+
+```
+QUEUE_CONNECTION=async-redis
+```
diff --git a/docs/advanced-usage/webhooks.md b/docs/advanced-usage/webhooks.md
new file mode 100644
index 0000000000..2df8e928ec
--- /dev/null
+++ b/docs/advanced-usage/webhooks.md
@@ -0,0 +1,53 @@
+---
+title: Webhooks
+order: 3
+---
+
+# Webhooks
+
+While you can create any custom websocket handlers, you might still want to intercept and run your own custom business logic on each websocket connection.
+
+In Pusher, there are [Pusher Webhooks](https://pusher.com/docs/channels/server_api/webhooks) that do this job. However, since the implementation is a pure controller,
+you might want to extend it and update the config file to reflect the changes:
+
+For example, running your own business logic on connection open and close:
+
+```php
+namespace App\Controllers\WebSockets;
+
+use BeyondCode\LaravelWebSockets\WebSockets\WebSocketHandler as BaseWebSocketHandler;
+use Ratchet\ConnectionInterface;
+
+class WebSocketHandler extends BaseWebSocketHandler
+{
+ public function onOpen(ConnectionInterface $connection)
+ {
+ parent::onOpen($connection);
+
+ // Run code on open
+ // $connection->app contains the app details
+ // $this->channelManager is accessible
+ }
+
+ public function onClose(ConnectionInterface $connection)
+ {
+ parent::onClose($connection);
+
+ // Run code on close.
+ // $connection->app contains the app details
+ // $this->channelManager is accessible
+ }
+}
+```
+
+Once you implemented it, replace the `handlers.websocket` class name in config:
+
+```php
+'handlers' => [
+
+ 'websocket' => App\Controllers\WebSockets\WebSocketHandler::class,
+
+],
+```
+
+A server restart is required afterwards.
diff --git a/docs/basic-usage/_index.md b/docs/basic-usage/_index.md
new file mode 100644
index 0000000000..40a50f6f67
--- /dev/null
+++ b/docs/basic-usage/_index.md
@@ -0,0 +1,4 @@
+---
+title: Basic Usage
+order: 2
+---
diff --git a/docs/basic-usage/pusher.md b/docs/basic-usage/pusher.md
new file mode 100644
index 0000000000..6d72a2d549
--- /dev/null
+++ b/docs/basic-usage/pusher.md
@@ -0,0 +1,129 @@
+---
+title: Pusher Replacement
+order: 1
+---
+
+# Pusher Replacement
+
+The easiest way to get started with Laravel WebSockets is by using it as a [Pusher](https://pusher.com) replacement. The integrated WebSocket and HTTP Server has complete feature parity with the Pusher WebSocket and HTTP API. In addition to that, this package also ships with an easy to use debugging dashboard to see all incoming and outgoing WebSocket requests.
+
+To make it clear, the package does not restrict connections numbers or depend on the Pusher's service. It does comply with the Pusher protocol to make it easy to use the Pusher SDK with it.
+
+## Requirements
+
+To make use of the Laravel WebSockets package in combination with Pusher, you first need to install the official Pusher PHP SDK.
+
+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).
+
+```bash
+composer require pusher/pusher-php-server "~4.0"
+```
+
+Next, you should make sure to use Pusher as your broadcasting driver. This can be achieved by setting the `BROADCAST_DRIVER` environment variable in your `.env` file:
+
+```
+BROADCAST_DRIVER=pusher
+```
+
+## Pusher Configuration
+
+When broadcasting events from your Laravel application to your WebSocket server, the default behavior is to send the event information to the official Pusher server. But since the Laravel WebSockets package comes with its own Pusher API implementation, we need to tell Laravel to send the events to our own server.
+
+To do this, you should add the `host` and `port` configuration key to your `config/broadcasting.php` and add it to the `pusher` section. The default port of the Laravel WebSocket server is 6001.
+
+```php
+'pusher' => [
+ 'driver' => 'pusher',
+ 'key' => env('PUSHER_APP_KEY'),
+ 'secret' => env('PUSHER_APP_SECRET'),
+ 'app_id' => env('PUSHER_APP_ID'),
+ 'options' => [
+ 'cluster' => env('PUSHER_APP_CLUSTER'),
+ 'encrypted' => true,
+ 'host' => env('PUSHER_APP_HOST', '127.0.0.1'),
+ 'port' => env('PUSHER_APP_PORT', 6001),
+ 'scheme' => env('PUSHER_APP_SCHEME', 'http'),
+ 'curl_options' => [
+ CURLOPT_SSL_VERIFYHOST => 0,
+ CURLOPT_SSL_VERIFYPEER => 0,
+ ],
+ ],
+],
+```
+
+## Configuring WebSocket Apps
+
+The Laravel WebSocket Pusher replacement server comes with multi-tenancy support out of the box. This means that you could host it independently from your current Laravel application and serve multiple WebSocket applications with one server.
+
+To make the move from an existing Pusher setup to this package as easy as possible, the default app simply uses your existing Pusher configuration.
+
+::: warning
+Make sure to use the same app id, key and secret as in your broadcasting configuration section. Otherwise broadcasting events from Laravel will not work.
+:::
+
+::: tip
+When using Laravel WebSockets as a Pusher replacement without having used Pusher before, it does not matter what you set as your `PUSHER_` variables. Just make sure they are unique for each project.
+:::
+
+You may add additional apps in your `config/websockets.php` file.
+
+```php
+'apps' => [
+ [
+ 'id' => env('PUSHER_APP_ID'),
+ 'name' => env('APP_NAME'),
+ 'key' => env('PUSHER_APP_KEY'),
+ 'secret' => env('PUSHER_APP_SECRET'),
+ 'path' => env('PUSHER_APP_PATH'),
+ 'capacity' => null,
+ 'enable_client_messages' => false,
+ 'enable_statistics' => true,
+ 'allowed_origins' => [],
+ ],
+],
+```
+
+### Client Messages
+
+For each app in your configuration file, you can define if this specific app should support a client-to-client messages. Usually all WebSocket messages go through your Laravel application before they will be broadcasted to other users. But sometimes you may want to enable a direct client-to-client communication instead of sending the events over the server. For example, a "typing" event in a chat application.
+
+It is important that you apply additional care when using client messages, since these originate from other users, and could be subject to tampering by a malicious user of your site.
+
+To enable or disable client messages, you can modify the `enable_client_messages` setting. The default value is `false`.
+
+### Statistics
+
+The Laravel WebSockets package comes with an out-of-the-box statistic solution that will give you key insights into the current status of your WebSocket server.
+
+To enable or disable the statistics for one of your apps, you can modify the `enable_statistics` setting. The default value is `true`.
+
+## Usage with Laravel Echo
+
+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.
+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).
+
+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.
+
+By default, the Pusher JavaScript client tries to send statistic information - you should disable this using the `disableStats` option.
+
+::: tip
+When using Laravel WebSockets in combination with a custom SSL certificate, be sure to use the `encrypted` option and set it to `true`.
+:::
+
+```js
+import Echo from 'laravel-echo';
+
+window.Pusher = require('pusher-js');
+
+window.Echo = new Echo({
+ broadcaster: 'pusher',
+ key: 'your-pusher-key',
+ wsHost: window.location.hostname,
+ wsPort: 6001,
+ forceTLS: false,
+ disableStats: true,
+ enabledTransports: ['ws', 'wss'],
+});
+```
+
+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).
diff --git a/docs/basic-usage/restarting.md b/docs/basic-usage/restarting.md
new file mode 100644
index 0000000000..56c5539289
--- /dev/null
+++ b/docs/basic-usage/restarting.md
@@ -0,0 +1,14 @@
+---
+title: Restarting Server
+order: 4
+---
+
+# Restarting Server
+
+If you use Supervisor to keep your server alive, you might want to restart it just like `queue:restart` does.
+
+To do so, consider using the `websockets:restart`. In a maximum of 10 seconds since issuing the command, the server will be restarted.
+
+```bash
+php artisan websockets:restart
+```
diff --git a/docs/basic-usage/sail.md b/docs/basic-usage/sail.md
new file mode 100644
index 0000000000..04265fbb0a
--- /dev/null
+++ b/docs/basic-usage/sail.md
@@ -0,0 +1,24 @@
+---
+title: Laravel Sail
+order: 5
+---
+
+# Run in Laravel Sail
+
+To be able to use Laravel Websockets in Sail, you should just forward the port:
+
+```yaml
+# For more information: https://laravel.com/docs/sail
+version: '3'
+services:
+ laravel.test:
+ build:
+ context: ./vendor/laravel/sail/runtimes/8.0
+ dockerfile: Dockerfile
+ args:
+ WWWGROUP: '${WWWGROUP}'
+ image: sail-8.0/app
+ ports:
+ - '${APP_PORT:-80}:80'
+ - '${LARAVEL_WEBSOCKETS_PORT:-6001}:${LARAVEL_WEBSOCKETS_PORT:-6001}'
+```
diff --git a/docs/basic-usage/ssl.md b/docs/basic-usage/ssl.md
new file mode 100644
index 0000000000..33092435d5
--- /dev/null
+++ b/docs/basic-usage/ssl.md
@@ -0,0 +1,291 @@
+---
+title: SSL Support
+order: 3
+---
+
+# SSL Support
+
+Since most of the web's traffic is going through HTTPS, it's also crucial to secure your WebSocket server. Luckily, adding SSL support to this package is really simple.
+
+## Configuration
+
+The SSL configuration takes place in your `config/websockets.php` file.
+
+The default configuration has a SSL section that looks like this:
+
+```php
+'ssl' => [
+
+ 'local_cert' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT', null),
+
+ 'capath' => env('LARAVEL_WEBSOCKETS_SSL_CA', null),
+
+ 'local_pk' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_PK', null),
+
+ 'passphrase' => env('LARAVEL_WEBSOCKETS_SSL_PASSPHRASE', null),
+
+ 'verify_peer' => env('APP_ENV') === 'production',
+
+ 'allow_self_signed' => env('APP_ENV') !== 'production',
+
+],
+```
+
+But this is only a subset of all the available configuration options.
+
+This packages makes use of the official PHP [SSL context options](http://php.net/manual/en/context.ssl.php).
+
+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.
+
+After setting up your SSL settings, you can simply (re)start your WebSocket server using:
+
+```bash
+php artisan websockets:serve
+```
+
+## Client configuration
+
+When your SSL settings are in place and working, you still need to tell Laravel Echo that it should make use of it.
+You can do this by specifying the `forceTLS` property in your JavaScript file, like this:
+
+```js
+import Echo from "laravel-echo"
+
+window.Pusher = require('pusher-js');
+
+window.Echo = new Echo({
+ broadcaster: 'pusher',
+ key: 'your-pusher-key',
+ wsHost: window.location.hostname,
+ wsPort: 6001,
+ disableStats: true,
+ forceTLS: true,
+ enabledTransports: ['ws', 'wss'],
+});
+```
+
+## Server configuration
+
+When broadcasting events from your Laravel application to the WebSocket server, you also need to tell Laravel to make use of HTTPS instead of HTTP. You can do this by setting the `PUSHER_APP_SCHEME` variable to `https`
+
+```env
+PUSHER_APP_SCHEME=https
+```
+
+Your connection from `config/broadcasting.php` would look like this:
+
+```php
+'pusher' => [
+ 'driver' => 'pusher',
+ 'key' => env('PUSHER_APP_KEY'),
+ 'secret' => env('PUSHER_APP_SECRET'),
+ 'app_id' => env('PUSHER_APP_ID'),
+ 'options' => [
+ 'cluster' => env('PUSHER_APP_CLUSTER'),
+ 'encrypted' => true,
+ 'host' => env('PUSHER_APP_HOST', '127.0.0.1'),
+ 'port' => env('PUSHER_APP_PORT', 6001),
+ 'scheme' => env('PUSHER_APP_SCHEME', 'http'),
+ ],
+],
+```
+
+Since the SSL configuration can vary quite a lot, depending on your setup, let's take a look at the most common approaches.
+
+## Usage with Laravel Valet
+
+Laravel Valet uses self-signed SSL certificates locally.
+To use self-signed certificates with Laravel WebSockets, here's how the SSL configuration section in your `config/websockets.php` file should look like.
+
+::: tip
+Make sure that you replace `YOUR-USERNAME` with your Mac username and `VALET-SITE.TLD` with the host of the Valet site that you're working on right now. For example `laravel-websockets-demo.test`.
+:::
+
+```php
+'ssl' => [
+
+ 'local_cert' => '/Users/YOUR-USERNAME/.config/valet/Certificates/VALET-SITE.TLD.crt',
+
+ 'capath' => env('LARAVEL_WEBSOCKETS_SSL_CA', null),
+
+ 'local_pk' => '/Users/YOUR-USERNAME/.config/valet/Certificates/VALET-SITE.TLD.key',
+
+ 'passphrase' => env('LARAVEL_WEBSOCKETS_SSL_PASSPHRASE', null),
+
+ 'verify_peer' => env('APP_ENV') === 'production',
+
+ 'allow_self_signed' => env('APP_ENV') !== 'production',
+
+],
+```
+
+Next, you need to adjust the `config/broadcasting.php` file to make use of a secure connection when broadcasting messages from Laravel to the WebSocket server.
+
+You also need to disable SSL verification.
+
+```php
+'pusher' => [
+ 'driver' => 'pusher',
+ 'key' => env('PUSHER_APP_KEY'),
+ 'secret' => env('PUSHER_APP_SECRET'),
+ 'app_id' => env('PUSHER_APP_ID'),
+ 'options' => [
+ 'cluster' => env('PUSHER_APP_CLUSTER'),
+ 'encrypted' => true,
+ 'host' => env('PUSHER_APP_HOST', '127.0.0.1'),
+ 'port' => env('PUSHER_APP_PORT', 6001),
+ 'scheme' => env('PUSHER_APP_SCHEME', 'http'),
+ 'curl_options' => [
+ CURLOPT_SSL_VERIFYHOST => 0,
+ CURLOPT_SSL_VERIFYPEER => 0,
+ ],
+ ],
+],
+```
+
+Last but not least, you still need to configure Laravel Echo to also use WSS on port 6001.
+
+```js
+window.Echo = new Echo({
+ broadcaster: 'pusher',
+ key: 'your-pusher-key',
+ wsHost: window.location.hostname,
+ wsPort: 6001,
+ wssPort: 6001,
+ disableStats: true,
+});
+```
+
+## Usage with a reverse proxy (like Nginx)
+
+Alternatively, you can also use a proxy service - like Nginx, HAProxy or Caddy - to handle the SSL configurations and proxy all requests in plain HTTP to your echo server.
+
+A basic Nginx configuration would look like this, but you might want to tweak the SSL parameters to your liking.
+
+```
+server {
+ listen 443 ssl;
+ listen [::]:443 ssl;
+ server_name socket.yourapp.tld;
+
+ # Start the SSL configurations
+ ssl on;
+ ssl_certificate /etc/letsencrypt/live/socket.yourapp.tld/fullchain.pem;
+ ssl_certificate_key /etc/letsencrypt/live/socket.yourapp.tld/privkey.pem;
+
+ location / {
+ proxy_pass http://127.0.0.1:6001;
+ proxy_read_timeout 60;
+ proxy_connect_timeout 60;
+ proxy_redirect off;
+
+ # Allow the use of websockets
+ proxy_http_version 1.1;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection 'upgrade';
+ proxy_set_header Host $host;
+ proxy_cache_bypass $http_upgrade;
+ }
+}
+```
+
+You can now talk HTTPS to `socket.yourapp.tld`. You would configure your `config/broadcasting.php` like the example above, treating your socket server as an `https` endpoint.
+
+### Same location for websockets and web contents
+
+To have the websockets be served at the same location and port as your other web content, Nginx can be taught to map incoming requests based on their type to special sub-locations.
+
+```
+map $http_upgrade $type {
+ default "web";
+ websocket "ws";
+}
+
+server {
+ # Your default configuration comes here...
+
+ location / {
+ try_files /nonexistent @$type;
+ }
+
+ location @web {
+ try_files $uri $uri/ /index.php?$query_string;
+ }
+
+ location @ws {
+ proxy_pass http://127.0.0.1:6001;
+ proxy_set_header Host $host;
+ proxy_read_timeout 60;
+ proxy_connect_timeout 60;
+ proxy_redirect off;
+
+ # Allow the use of websockets
+ proxy_http_version 1.1;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection 'upgrade';
+ proxy_set_header Host $host;
+ proxy_cache_bypass $http_upgrade;
+ }
+}
+```
+
+This configuration is useful if you do not want to open multiple ports or you are restricted to which ports are already opened on your server. Alternatively, a second Nginx location can be used on the server-side, while the Pusher configuration [`wsPath`](https://github.com/pusher/pusher-js#wspath) can be used on the client-side (_note: `"pusher-js": ">=4.2.2"` is required for this configuration option_).
+
+```
+server {
+ # Your default configuration comes here...
+
+ location /ws {
+ proxy_pass http://127.0.0.1:6001;
+ proxy_set_header Host $host;
+ proxy_read_timeout 60;
+ proxy_connect_timeout 60;
+ proxy_redirect off;
+
+ # Allow the use of websockets
+ proxy_http_version 1.1;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection 'upgrade';
+ proxy_set_header Host $host;
+ proxy_cache_bypass $http_upgrade;
+ }
+}
+```
+
+### Nginx worker connections
+
+Note that you might need to increase the amount of `worker_connections` in Nginx. Your WebSocket connections will now be sent to Nginx, which in turn will send those along to the websocket server.
+
+By default, that will have a sane limit of 1024 connections. If you are expecting more concurrent connections to your WebSockets, you can increase this in your global `nginx.conf`.
+
+```
+events {
+ worker_connections 1024;
+}
+```
+
+You know you've reached this limit of your Nginx error logs contain similar messages to these:
+
+```
+[alert] 1024 worker_connections are not enough while connecting to upstream
+```
+
+Remember to restart your Nginx after you've modified the `worker_connections`.
+
+### Example using Caddy v2
+
+[Caddy](https://caddyserver.com) can also be used to automatically obtain a TLS certificate from Let's Encrypt and terminate TLS before proxying to your websocket server.
+
+An example configuration would look like this:
+
+```
+socket.yourapp.tld {
+ @ws {
+ header Connection *Upgrade*
+ header Upgrade websocket
+ }
+ reverse_proxy @ws 127.0.0.1:6001
+}
+```
+
+Note that you should change `127.0.0.1` to the hostname of your websocket server. For example, if you're running in a Docker environment, this might be the container name of your websocket server.
diff --git a/docs/basic-usage/starting.md b/docs/basic-usage/starting.md
new file mode 100644
index 0000000000..6b28439778
--- /dev/null
+++ b/docs/basic-usage/starting.md
@@ -0,0 +1,32 @@
+---
+title: Starting the WebSocket server
+order: 2
+---
+
+# Starting the WebSocket server
+
+Once you have configured your WebSocket apps and Pusher settings, you can start the Laravel WebSocket server by issuing the artisan command:
+
+```bash
+php artisan websockets:serve
+```
+
+## Using a different port
+
+The default port of the Laravel WebSocket server is `6001`. You may pass a different port to the command using the `--port` option.
+
+```bash
+php artisan websockets:serve --port=3030
+```
+
+This will start listening on port `3030`.
+
+## Restricting the listening host
+
+By default, the Laravel WebSocket server will listen on `0.0.0.0` and will allow incoming connections from all networks. If you want to restrict this, you can start the server with a `--host` option, followed by an IP.
+
+For example, by using `127.0.0.1`, you will only allow WebSocket connections from localhost.
+
+```bash
+php artisan websockets:serve --host=127.0.0.1
+```
diff --git a/docs/debugging/_index.md b/docs/debugging/_index.md
new file mode 100644
index 0000000000..448f29679e
--- /dev/null
+++ b/docs/debugging/_index.md
@@ -0,0 +1,4 @@
+---
+title: Debugging
+order: 3
+---
diff --git a/docs/debugging/console.md b/docs/debugging/console.md
new file mode 100644
index 0000000000..cf0e97a652
--- /dev/null
+++ b/docs/debugging/console.md
@@ -0,0 +1,12 @@
+---
+title: Console Logging
+order: 1
+---
+
+# Console Logging
+
+When you start the Laravel WebSocket server and your application is in debug mode, you will automatically see all incoming and outgoing WebSocket events in your terminal.
+
+On production environments, you shall use the `--debug` flag to display the events in the terminal.
+
+
diff --git a/docs/debugging/dashboard.md b/docs/debugging/dashboard.md
new file mode 100644
index 0000000000..bba0551bf7
--- /dev/null
+++ b/docs/debugging/dashboard.md
@@ -0,0 +1,84 @@
+---
+title: Debug Dashboard
+order: 2
+---
+
+# Debug Dashboard
+
+In addition to logging the events to the console, you can also use a real-time dashboard that shows you all incoming connections, events and disconnects the moment they happen on your WebSocket server.
+
+
+
+## Accessing the Dashboard
+
+The default location of the WebSocket dashboard is at `/laravel-websockets`. The routes get automatically registered.
+If you want to change the URL of the dashboard, you can configure it with the `path` setting in your `config/websockets.php` file.
+
+To access the debug dashboard, you can visit the dashboard URL of your Laravel project in the browser
+Since your WebSocket server has support for multiple apps, you can select which app you want to connect to and inspect.
+
+By pressing the "Connect" button, you can establish the WebSocket connection and see all events taking place on your WebSocket server from there on in real-time.
+
+**Note:** Be sure to set the ``APP_URL`` env variable to match the current URL where your project is running to be sure the stats graph works properly.
+
+## Protecting the Dashboard
+
+By default, access to the WebSocket dashboard is only allowed while your application environment is set to `local`.
+
+However, you can change this behavior by overriding the Laravel Gate being used. A good place for this is the `AuthServiceProvider` that ships with Laravel.
+
+```php
+public function boot()
+{
+ $this->registerPolicies();
+
+ Gate::define('viewWebSocketsDashboard', function ($user = null) {
+ return in_array($user->email, [
+ //
+ ]);
+ });
+}
+```
+
+## Statistics
+
+This package allows you to record key metrics of your WebSocket server. The WebSocket server will store a snapshot of the current number of peak connections, the amount of received WebSocket messages and the amount of received API messages defined in a fixed interval. The default setting is to store a snapshot every 60 seconds.
+
+In addition to simply storing the statistic information in your database, you can also see the statistics as they happen in real-time on the debug dashboard.
+
+
+
+You can modify this interval by changing the `interval_in_seconds` setting in your config file.
+
+## Cleanup old Statistics
+
+After using the WebSocket server for a while you will have recorded a lot of statistical data that you might no longer need. This package provides an artisan command `websockets:clean` to clean these statistic log entries.
+
+Running this command will result in the deletion of all recorded statistics that are older than the number of days specified in the `delete_statistics_older_than_days` setting of the config file.
+
+You can leverage Laravel's scheduler to run the clean up command now and then.
+
+```php
+//app/Console/Kernel.php
+
+protected function schedule(Schedule $schedule)
+{
+ $schedule->command('websockets:clean')->daily();
+}
+```
+
+## Disable Statistics
+
+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.
+
+However, to disable it entirely and void any incoming statistic, you can call `--disable-statistics` when running the server command:
+
+```bash
+php artisan websockets:serve --disable-statistics
+```
+
+## Event Creator
+
+The dashboard also comes with an easy-to-use event creator, that lets you manually send events to your channels.
+
+Simply enter the channel, the event name and provide a valid JSON payload to send it to all connected clients in the given channel.
diff --git a/docs/faq/_index.md b/docs/faq/_index.md
new file mode 100644
index 0000000000..47b9d3aa0f
--- /dev/null
+++ b/docs/faq/_index.md
@@ -0,0 +1,4 @@
+---
+title: FAQ
+order: 6
+---
diff --git a/docs/faq/cloudflare.md b/docs/faq/cloudflare.md
new file mode 100644
index 0000000000..d5a933a9ea
--- /dev/null
+++ b/docs/faq/cloudflare.md
@@ -0,0 +1,18 @@
+---
+title: Cloudflare
+order: 3
+---
+
+# Cloudflare
+
+In some cases, you might use Cloudflare and notice that your production server does not seem to respond to your `:6001` port.
+
+This is because Cloudflare does not seem to open ports, [excepting a few of them](https://blog.cloudflare.com/cloudflare-now-supporting-more-ports/).
+
+To mitigate this issue, for example, you can run your server on port `2096`:
+
+```bash
+php artisan websockets:serve --port=2096
+```
+
+You will notice that the new `:2096` websockets server will work properly.
diff --git a/docs/faq/deploying.md b/docs/faq/deploying.md
new file mode 100644
index 0000000000..8cca2dc58d
--- /dev/null
+++ b/docs/faq/deploying.md
@@ -0,0 +1,106 @@
+---
+title: Deploying
+order: 1
+---
+
+# Deploying
+
+When your application is ready to get deployed, here are some tips to improve your WebSocket server.
+
+### Open Connection Limit
+
+On Unix systems, every user that connects to your WebSocket server is represented as a file somewhere on the system.
+As a security measurement of every Unix based OS, the number of "file descriptors" an application may have open at a time is limited - most of the time to a default value of 1024 - which would result in a maximum number of 1024 concurrent users on your WebSocket server.
+
+In addition to the OS restrictions, this package makes use of an event loop called "stream_select", which has a hard limit of 1024.
+
+#### Increasing the maximum number of file descriptors
+
+The operating system limit of open "file descriptors" can be increased using the `ulimit` command. The `-n` option modifies the number of open file descriptors.
+
+```bash
+ulimit -n 10000
+```
+
+The `ulimit` command only **temporarily** increases the maximum number of open file descriptors. To permanently modify this value, you can edit it in your operating system `limits.conf` file.
+
+You are best to do so by creating a file in the `limits.d` directory. This will work for both Red Hat & Ubuntu derivatives.
+
+```bash
+$ cat /etc/security/limits.d/laravel-echo.conf
+laravel-echo soft nofile 10000
+```
+
+The above example assumes you will run your echo server as the `laravel-echo` user, you are free to change that to your liking.
+
+#### Changing the event loop
+
+To make use of a different event loop, that does not have a hard limit of 1024 concurrent connections, you can either install the `ev` or `event` PECL extension using:
+
+```bash
+sudo pecl install ev
+# or
+sudo pecl install event
+```
+
+#### Deploying on Laravel Forge
+
+If your are using [Laravel Forge](https://forge.laravel.com/) for the deployment [this article by Alex Bouma](https://alex.bouma.dev/installing-laravel-websockets-on-forge) might help you out.
+
+#### Deploying on Laravel Vapor
+
+Since [Laravel Vapor](https://vapor.laravel.com) runs on a serverless architecture, you will need to spin up an actual EC2 Instance that runs in the same VPC as the Lambda function to be able to make use of the WebSocket connection.
+
+The Lambda function will make sure your HTTP request gets fulfilled, then the EC2 Instance will be continuously polled through the WebSocket protocol.
+
+## Keeping the socket server running with supervisord
+
+The `websockets:serve` daemon needs to always be running in order to accept connections. This is a prime use case for `supervisor`, a task runner on Linux.
+
+First, make sure `supervisor` is installed.
+
+```bash
+# On Debian / Ubuntu
+apt install supervisor
+
+# On Red Hat / CentOS
+yum install supervisor
+systemctl enable supervisord
+```
+
+Once installed, add a new process that `supervisor` needs to keep running. You place your configurations in the `/etc/supervisor/conf.d` (Debian/Ubuntu) or `/etc/supervisord.d` (Red Hat/CentOS) directory.
+
+Within that directory, create a new file called `websockets.conf`.
+
+```bash
+[program:websockets]
+command=/usr/bin/php /home/laravel-echo/laravel-websockets/artisan websockets:serve
+numprocs=1
+autostart=true
+autorestart=true
+user=laravel-echo
+```
+
+Once created, instruct `supervisor` to reload its configuration files (without impacting the already running `supervisor` jobs).
+
+```bash
+supervisorctl update
+supervisorctl start websockets
+```
+
+Your echo server should now be running (you can verify this with `supervisorctl status`). If it were to crash, `supervisor` will automatically restart it.
+
+Please note that, by default, just like file descriptiors, `supervisor` will force a maximum number of open files onto all the processes that it manages. This is configured by the `minfds` parameter in `supervisord.conf`.
+
+If you want to increase the maximum number of open files, you may do so in `/etc/supervisor/supervisord.conf` (Debian/Ubuntu) or `/etc/supervisord.conf` (Red Hat/CentOS):
+
+```
+[supervisord]
+minfds=10240; (min. avail startup file descriptors;default 1024)
+```
+
+After changing this setting, you'll need to restart the supervisor process (which in turn will restart all your processes that it manages).
+
+## Debugging supervisor
+
+If you run into issues with Supervisor, like not supporting a lot of connections, consider checking the [Ratched docs on deploying with Supervisor](http://socketo.me/docs/deploy#supervisor).
diff --git a/docs/faq/scaling.md b/docs/faq/scaling.md
new file mode 100644
index 0000000000..b5033f0ec5
--- /dev/null
+++ b/docs/faq/scaling.md
@@ -0,0 +1,22 @@
+---
+title: Benchmarks
+order: 2
+---
+
+# Benchmarks
+
+Of course, this is not a question with an easy answer as your mileage may vary. But with the appropriate server-side configuration your WebSocket server can easily hold a **lot** of concurrent connections.
+
+This is an example benchmark that was done on the smallest Digital Ocean droplet, that also had a couple of other Laravel projects running. On this specific server, the maximum number of **concurrent** connections ended up being ~15,000.
+
+
+
+Here is another benchmark that was run on a 2GB Digital Ocean droplet with 2 CPUs. The maximum number of **concurrent** connections on this server setup is nearly 60,000.
+
+
+
+Make sure to take a look at the [Deployment Tips](/docs/laravel-websockets/faq/deploying) to find out how to improve your specific setup.
+
+# Horizontal Scaling
+
+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.
diff --git a/docs/getting-started/_index.md b/docs/getting-started/_index.md
new file mode 100644
index 0000000000..7f67f57707
--- /dev/null
+++ b/docs/getting-started/_index.md
@@ -0,0 +1,4 @@
+---
+title: Getting Started
+order: 1
+---
diff --git a/docs/getting-started/installation.md b/docs/getting-started/installation.md
new file mode 100644
index 0000000000..5d24d7dd6a
--- /dev/null
+++ b/docs/getting-started/installation.md
@@ -0,0 +1,36 @@
+---
+title: Installation
+order: 2
+---
+
+# Installation
+
+Laravel WebSockets can be installed via composer:
+
+```bash
+composer require beyondcode/laravel-websockets
+```
+
+The package will automatically register a service provider.
+
+You need to publish the WebSocket configuration file:
+
+```bash
+php artisan vendor:publish --provider="BeyondCode\LaravelWebSockets\WebSocketsServiceProvider" --tag="config"
+```
+
+# Statistics
+
+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.
+
+You can publish the migration file using:
+
+```bash
+php artisan vendor:publish --provider="BeyondCode\LaravelWebSockets\WebSocketsServiceProvider" --tag="migrations"
+```
+
+Run the migrations with:
+
+```bash
+php artisan migrate
+```
diff --git a/docs/getting-started/introduction.md b/docs/getting-started/introduction.md
new file mode 100644
index 0000000000..0e5050aee8
--- /dev/null
+++ b/docs/getting-started/introduction.md
@@ -0,0 +1,22 @@
+---
+title: Introduction
+order: 1
+---
+
+# Laravel WebSockets 🛰
+
+WebSockets for Laravel. Done right.
+
+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.
+
+Once installed, you can start it with one simple command:
+
+```php
+php artisan websockets:serve
+```
+
+---
+
+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.
+
+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.
diff --git a/docs/getting-started/questions-issues.md b/docs/getting-started/questions-issues.md
new file mode 100644
index 0000000000..791221618a
--- /dev/null
+++ b/docs/getting-started/questions-issues.md
@@ -0,0 +1,10 @@
+---
+title: Questions and issues
+order: 3
+---
+
+# Questions and issues
+
+Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving laravel-websockets? Feel free to create an issue on [GitHub](https://github.com/beyondcode/laravel-websockets/issues), we'll try to address it as soon as possible.
+
+If you've found a bug regarding security please mail [marcel@beyondco.de](mailto:marcel@beyondco.de) instead of using the issue tracker.
\ No newline at end of file
diff --git a/docs/horizontal-scaling/_index.md b/docs/horizontal-scaling/_index.md
new file mode 100644
index 0000000000..f66c2b551e
--- /dev/null
+++ b/docs/horizontal-scaling/_index.md
@@ -0,0 +1,4 @@
+---
+title: Horizontal Scaling
+order: 5
+---
diff --git a/docs/horizontal-scaling/getting-started.md b/docs/horizontal-scaling/getting-started.md
new file mode 100644
index 0000000000..1bb3ab42d8
--- /dev/null
+++ b/docs/horizontal-scaling/getting-started.md
@@ -0,0 +1,34 @@
+---
+title: Getting Started
+order: 1
+---
+
+When running Laravel WebSockets without additional configuration, you won't be able to scale your servers out.
+
+For example, even with Sticky Load Balancer settings, you won't be able to keep track of your users' connections to notify them properly when messages occur if you got multiple nodes that run the same `websockets:serve` command.
+
+The reason why this happen is because the default channel manager runs on arrays, which is not a database other instances can access.
+
+To do so, we need a database and a way of notifying other instances when connections occur.
+
+For example, Redis does a great job by encapsulating the both the way of notifying (Pub/Sub module) and the storage (key-value datastore).
+
+## Configure the replication
+
+To enable the replication, simply change the `replication.mode` name in the `websockets.php` file:
+
+```php
+'replication' => [
+
+ 'mode' => 'redis',
+
+ ...
+
+],
+```
+
+Now, when your app broadcasts the message, it will make sure the connection reaches other servers which are under the same load balancer.
+
+The available drivers for replication are:
+
+- [Redis](redis)
diff --git a/docs/horizontal-scaling/redis.md b/docs/horizontal-scaling/redis.md
new file mode 100644
index 0000000000..4f6383583b
--- /dev/null
+++ b/docs/horizontal-scaling/redis.md
@@ -0,0 +1,42 @@
+---
+title: Redis Mode
+order: 2
+---
+
+# Redis Mode
+
+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.
+
+## Configure Redis mode
+
+To enable the replication, simply change the `replication.mode` name in the `websockets.php` file to `redis`:
+
+```php
+'replication' => [
+
+ 'mode' => 'redis',
+
+ ...
+
+],
+```
+
+You can set the connection name to the Redis database under `redis`:
+
+```php
+'replication' => [
+
+ 'modes' =>
+
+ 'redis' => [
+
+ 'connection' => 'default',
+
+ ],
+
+ ],
+
+],
+```
+
+The connections can be found in your `config/database.php` file, under the `redis` key.
diff --git a/phpunit.xml.dist b/phpunit.xml
similarity index 63%
rename from phpunit.xml.dist
rename to phpunit.xml
index 5102c747e3..229ec35459 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml
@@ -10,7 +10,7 @@
processIsolation="false"
stopOnFailure="false">
| + Name + | ++ Allowed origins + | ++ Statistics + | ++ Client Messages + | ++ |
|---|---|---|---|---|
| + @{{ app.name }} + | ++ @{{ app.allowed_origins || '*' }} + | ++ Yes + No + | ++ Yes + No + | ++ Installation instructions + Delete + | +
Modify your .env file:
PUSHER_APP_HOST=@{{ app.host === null ? window.location.hostname : app.host }}
+PUSHER_APP_PORT={{ $port }}
+PUSHER_APP_KEY=@{{ app.key }}
+PUSHER_APP_ID=@{{ app.id }}
+PUSHER_APP_SECRET=@{{ app.secret }}
+PUSHER_APP_SCHEME=https
+MIX_PUSHER_APP_HOST="${PUSHER_APP_HOST}"
+MIX_PUSHER_APP_PORT="${PUSHER_APP_PORT}"
+MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
+ | Type | -Socket | -Details | -Time | -
|---|---|---|---|
| @{{ log.type }} | -@{{ log.socketId }} | -@{{ log.details }} | -@{{ log.time }} | -