@@ -17,12 +17,17 @@ class Commands extends Command
1717
1818 public function handle ()
1919 {
20+ $ this ->checkEventFile ();
21+
22+ $ this ->info ('Welcome use Workerman server ' );
23+
2024 global $ argv ;
2125
2226 $ action = $ this ->argument ('action ' );
2327
2428 if (!in_array ($ action , ['start ' , 'stop ' , 'restart ' , 'reload ' , 'status ' , 'connections ' ])) {
25- return 'Error ' ;
29+ echo "Error " ;
30+ return ;
2631 }
2732 $ argv [1 ] = $ action ;
2833 $ argv [2 ] = $ this ->option ('d ' ) ? '-d ' : '' ;
@@ -77,4 +82,29 @@ private function startRegister()
7782 {
7883 new Register ('text://0.0.0.0:1236 ' );
7984 }
85+
86+ private function checkEventFile ()
87+ {
88+ if (!is_dir (app_path ('Workerman ' ))) {
89+ $ this ->warn ('Workerman Path Notexist ' );
90+ $ this ->laravel ['files ' ]->makeDirectory (app_path ('Workerman ' ), 0755 , true , true );
91+ $ this ->info ('Make Workerman Path was created. ' );
92+ }
93+
94+ $ eventFile = app_path ('Workerman/Events.php ' );
95+ if (file_exists ($ eventFile )) {
96+ $ this ->info ('Workerman EventFile already exists ' );
97+ } else {
98+ $ contents = $ this ->getStub ('event ' );
99+ $ this ->warn ('Workerman EventFile Notexist ' );
100+ $ this ->laravel ['files ' ]->put ($ eventFile , $ contents );
101+ $ this ->info ('Make Workerman EventFile was created. ' );
102+ }
103+ }
104+
105+ private function getStub ($ name )
106+ {
107+ return $ this ->laravel ['files ' ]->get (__DIR__ . "/stubs/ $ name.stub " );
108+ }
109+
80110}
0 commit comments