@@ -79,6 +79,7 @@ public function configure(): void
79
79
$ this ->defaultWorkers
80
80
)
81
81
->addOption ('env ' , 'e ' , InputOption::VALUE_OPTIONAL , 'It is only used for testing. ' )
82
+ ->addOption ('open ' , 'o ' , InputOption::VALUE_OPTIONAL , 'Opens the serving server in the default browser. ' )
82
83
->addOption ('xdebug ' , 'x ' , InputOption::VALUE_OPTIONAL , 'Enables XDEBUG session. ' , false );
83
84
}
84
85
@@ -149,7 +150,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
149
150
}
150
151
151
152
$ xDebugInstalled = extension_loaded ('xdebug ' );
152
- $ xDebugEnabled = $ isLinux && $ xDebugInstalled && $ input ->hasOption ('xdebug ' ) && $ input ->getOption ('xdebug ' );
153
+ $ xDebugEnabled = $ isLinux && $ xDebugInstalled && $ input ->hasOption ('xdebug ' ) && $ input ->getOption ('xdebug ' ) === null ;
153
154
154
155
if ($ xDebugEnabled ) {
155
156
$ command [] = 'XDEBUG_MODE=debug XDEBUG_TRIGGER=yes ' ;
@@ -161,15 +162,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
161
162
$ xDebugInstalled ? sprintf (
162
163
'%s, %s ' ,
163
164
phpversion ('xdebug ' ),
164
- $ xDebugEnabled ? '<info>enabled </> ' : '<error>disabled. Add --xdebug 1 to enable </> ' ,
165
+ $ xDebugEnabled ? '<info> Enabled </> ' : '<error> Disabled </> ' ,
165
166
) : '<error>Not installed</> ' ,
167
+ '--xdebug ' ,
166
168
];
167
- $ outputTable [] = ['Workers ' , $ isLinux ? $ workers : 'Not supported ' ];
169
+ $ outputTable [] = ['Workers ' , $ isLinux ? $ workers : 'Not supported ' , ' --workers, -w ' ];
168
170
$ outputTable [] = ['Address ' , $ address ];
169
- $ outputTable [] = ['Document root ' , $ documentRoot ];
170
- $ outputTable [] = ($ router ? ['Routing file ' , $ router ] : []);
171
+ $ outputTable [] = ['Document root ' , $ documentRoot, ' --docroot, -t ' ];
172
+ $ outputTable [] = ($ router ? ['Routing file ' , $ router, ' --router, -r ' ] : []);
171
173
172
- $ io ->table (['Configuration ' ], $ outputTable );
174
+ $ io ->table (['Configuration ' , null , ' Options ' ], $ outputTable );
173
175
174
176
$ command [] = '" ' . PHP_BINARY . '" ' . " -S $ address -t \"$ documentRoot \" $ router " ;
175
177
$ command = implode (' ' , $ command );
@@ -185,6 +187,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
185
187
return ExitCode::OK ;
186
188
}
187
189
190
+ $ openInBrowser = $ input ->hasOption ('open ' ) && $ input ->getOption ('open ' ) === null ;
191
+
192
+ if ($ openInBrowser ) {
193
+ passthru ('open http:// ' . $ address );
194
+ }
188
195
passthru ($ command , $ result );
189
196
190
197
return $ result ;
0 commit comments