@@ -38,14 +38,35 @@ abstract class HttpServiceProvider extends ServiceProvider
3838 protected static $ server ;
3939
4040 /**
41- * Register the service provider.
41+ * Boot the service provider.
4242 *
4343 * @return void
4444 */
45- public function register ()
45+ public function boot ()
4646 {
47+ $ this ->publishFiles ();
48+ $ this ->loadConfigs ();
4749 $ this ->mergeConfigs ();
4850 $ this ->setIsWebsocket ();
51+
52+ $ config = $ this ->app ->make ('config ' );
53+
54+ if ($ config ->get ('swoole_http.websocket.enabled ' )) {
55+ $ this ->bootWebsocketRoutes ();
56+ }
57+
58+ if ($ config ->get ('swoole_http.server.access_log ' )) {
59+ $ this ->pushAccessLogMiddleware ();
60+ }
61+ }
62+
63+ /**
64+ * Register the service provider.
65+ *
66+ * @return void
67+ */
68+ public function register ()
69+ {
4970 $ this ->registerServer ();
5071 $ this ->registerManager ();
5172 $ this ->registerCommands ();
@@ -76,27 +97,23 @@ abstract protected function bootWebsocketRoutes();
7697 abstract protected function pushAccessLogMiddleware ();
7798
7899 /**
79- * Boot the service provider.
80- *
81- * @return void
100+ * Publish files of this package.
82101 */
83- public function boot ()
102+ protected function publishFiles ()
84103 {
85104 $ this ->publishes ([
86105 __DIR__ . '/../config/swoole_http.php ' => base_path ('config/swoole_http.php ' ),
87106 __DIR__ . '/../config/swoole_websocket.php ' => base_path ('config/swoole_websocket.php ' ),
88107 __DIR__ . '/../routes/websocket.php ' => base_path ('routes/websocket.php ' ),
89108 ], 'laravel-swoole ' );
109+ }
90110
91- $ config = $ this ->app ->make ('config ' );
92-
93- if ($ config ->get ('swoole_http.websocket.enabled ' )) {
94- $ this ->bootWebsocketRoutes ();
95- }
96-
97- if ($ config ->get ('swoole_http.server.access_log ' )) {
98- $ this ->pushAccessLogMiddleware ();
99- }
111+ /**
112+ * Load configurations.
113+ */
114+ protected function loadConfigs ()
115+ {
116+ // do nothing
100117 }
101118
102119 /**
0 commit comments