diff --git a/src/Console/StartWebSocketServer.php b/src/Console/StartWebSocketServer.php index 89dd205b35..9913aff503 100644 --- a/src/Console/StartWebSocketServer.php +++ b/src/Console/StartWebSocketServer.php @@ -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); }); @@ -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()); }); @@ -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()); }); @@ -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()); }); diff --git a/src/WebSocketsServiceProvider.php b/src/WebSocketsServiceProvider.php index 1e30ed352b..256812542d 100644 --- a/src/WebSocketsServiceProvider.php +++ b/src/WebSocketsServiceProvider.php @@ -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']); }); }