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

[1.x] Laravel Octane fixes #734

Merged
merged 1 commit into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/Console/StartWebSocketServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ protected function configureStatisticsLogger()

$browser = new Browser($this->loop, $connector);

app()->singleton(StatisticsLoggerInterface::class, function () use ($browser) {
$class = config('websockets.statistics.logger', \BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger::class);
app()->singleton(StatisticsLoggerInterface::class, function ($app) use ($browser) {
$config = $app['config']['websockets'];
$class = $config['statistics']['logger'] ?? \BeyondCode\LaravelWebSockets\Statistics\Logger\HttpStatisticsLogger::class;

return new $class(app(ChannelManager::class), $browser);
});
Expand All @@ -79,9 +80,9 @@ protected function configureStatisticsLogger()

protected function configureHttpLogger()
{
app()->singleton(HttpLogger::class, function () {
app()->singleton(HttpLogger::class, function ($app) {
return (new HttpLogger($this->output))
->enable($this->option('debug') ?: config('app.debug'))
->enable($this->option('debug') ?: ($app['config']['app']['debug'] ?? false))
->verbose($this->output->isVerbose());
});

Expand All @@ -90,9 +91,9 @@ protected function configureHttpLogger()

protected function configureMessageLogger()
{
app()->singleton(WebsocketsLogger::class, function () {
app()->singleton(WebsocketsLogger::class, function ($app) {
return (new WebsocketsLogger($this->output))
->enable($this->option('debug') ?: config('app.debug'))
->enable($this->option('debug') ?: ($app['config']['app']['debug'] ?? false))
->verbose($this->output->isVerbose());
});

Expand All @@ -101,9 +102,9 @@ protected function configureMessageLogger()

protected function configureConnectionLogger()
{
app()->bind(ConnectionLogger::class, function () {
app()->bind(ConnectionLogger::class, function ($app) {
return (new ConnectionLogger($this->output))
->enable(config('app.debug'))
->enable($app['config']['app']['debug'] ?? false)
->verbose($this->output->isVerbose());
});

Expand Down
14 changes: 9 additions & 5 deletions src/WebSocketsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@ public function register()
return new Router();
});

$this->app->singleton(ChannelManager::class, function () {
return config('websockets.channel_manager') !== null && class_exists(config('websockets.channel_manager'))
? app(config('websockets.channel_manager')) : new ArrayChannelManager();
$this->app->singleton(ChannelManager::class, function ($app) {
$config = $app['config']['websockets'];

return ($config['channel_manager'] ?? null) !== null && class_exists($config['channel_manager'])
? app($config['channel_manager']) : new ArrayChannelManager();
});

$this->app->singleton(AppProvider::class, function () {
return app(config('websockets.app_provider'));
$this->app->singleton(AppProvider::class, function ($app) {
$config = $app['config']['websockets'];

return app($config['app_provider']);
});
}

Expand Down