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

Commit ba3a2ad

Browse files
driesvintsrennokki
andauthored
[2.x] Laravel Octane support (#733)
* Octane support Co-authored-by: Alex Renoki <[email protected]>
1 parent 1bb727f commit ba3a2ad

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

Diff for: src/Console/Commands/StartServer.php

+10-9
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,11 @@ protected function configureLoggers()
106106
*/
107107
protected function configureManagers()
108108
{
109-
$this->laravel->singleton(ChannelManager::class, function () {
110-
$mode = config('websockets.replication.mode', 'local');
109+
$this->laravel->singleton(ChannelManager::class, function ($app) {
110+
$config = $app['config']['websockets'];
111+
$mode = $config['replication']['mode'] ?? 'local';
111112

112-
$class = config("websockets.replication.modes.{$mode}.channel_manager");
113+
$class = $config['replication']['modes'][$mode]['channel_manager'];
113114

114115
return new $class($this->loop);
115116
});
@@ -211,9 +212,9 @@ protected function configurePongTracker()
211212
*/
212213
protected function configureHttpLogger()
213214
{
214-
$this->laravel->singleton(HttpLogger::class, function () {
215+
$this->laravel->singleton(HttpLogger::class, function ($app) {
215216
return (new HttpLogger($this->output))
216-
->enable($this->option('debug') ?: config('app.debug'))
217+
->enable($this->option('debug') ?: ($app['config']['app']['debug'] ?? false))
217218
->verbose($this->output->isVerbose());
218219
});
219220
}
@@ -225,9 +226,9 @@ protected function configureHttpLogger()
225226
*/
226227
protected function configureMessageLogger()
227228
{
228-
$this->laravel->singleton(WebSocketsLogger::class, function () {
229+
$this->laravel->singleton(WebSocketsLogger::class, function ($app) {
229230
return (new WebSocketsLogger($this->output))
230-
->enable($this->option('debug') ?: config('app.debug'))
231+
->enable($this->option('debug') ?: ($app['config']['app']['debug'] ?? false))
231232
->verbose($this->output->isVerbose());
232233
});
233234
}
@@ -239,9 +240,9 @@ protected function configureMessageLogger()
239240
*/
240241
protected function configureConnectionLogger()
241242
{
242-
$this->laravel->bind(ConnectionLogger::class, function () {
243+
$this->laravel->bind(ConnectionLogger::class, function ($app) {
243244
return (new ConnectionLogger($this->output))
244-
->enable(config('app.debug'))
245+
->enable($app['config']['app']['debug'] ?? false)
245246
->verbose($this->output->isVerbose());
246247
});
247248
}

Diff for: src/WebSocketsServiceProvider.php

+11-7
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,18 @@ protected function registerAsyncRedisQueueDriver()
8080
*/
8181
protected function registerStatistics()
8282
{
83-
$this->app->singleton(StatisticsStore::class, function () {
84-
$class = config('websockets.statistics.store');
83+
$this->app->singleton(StatisticsStore::class, function ($app) {
84+
$config = $app['config']['websockets'];
85+
$class = $config['statistics']['store'];
8586

8687
return new $class;
8788
});
8889

89-
$this->app->singleton(StatisticsCollector::class, function () {
90-
$replicationMode = config('websockets.replication.mode', 'local');
90+
$this->app->singleton(StatisticsCollector::class, function ($app) {
91+
$config = $app['config']['websockets'];
92+
$replicationMode = $config['replication']['mode'] ?? 'local';
9193

92-
$class = config("websockets.replication.modes.{$replicationMode}.collector");
94+
$class = $config['replication']['modes'][$replicationMode]['collector'];
9395

9496
return new $class;
9597
});
@@ -142,8 +144,10 @@ protected function registerRouter()
142144
*/
143145
protected function registerManagers()
144146
{
145-
$this->app->singleton(Contracts\AppManager::class, function () {
146-
return $this->app->make(config('websockets.managers.app'));
147+
$this->app->singleton(Contracts\AppManager::class, function ($app) {
148+
$config = $app['config']['websockets'];
149+
150+
return $this->app->make($config['managers']['app']);
147151
});
148152
}
149153

0 commit comments

Comments
 (0)