File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 15
15
use function fclose ;
16
16
use function proc_open ;
17
17
use function stream_get_contents ;
18
+ use const DIRECTORY_SEPARATOR ;
18
19
19
20
/**
20
21
* Class ProcFuncWrapper
@@ -223,7 +224,7 @@ public function open(): self
223
224
$ options = $ this ->options ;
224
225
225
226
$ options ['suppress_errors ' ] = true ;
226
- if ('\\' === \ DIRECTORY_SEPARATOR ) {
227
+ if ('\\' === DIRECTORY_SEPARATOR ) { // windows
227
228
$ options ['bypass_shell ' ] = true ;
228
229
}
229
230
Original file line number Diff line number Diff line change @@ -164,6 +164,35 @@ public static function getOutsideIP(): string
164
164
return 'unknown ' ;
165
165
}
166
166
167
+ /**
168
+ * Open browser URL
169
+ *
170
+ * Mac:
171
+ * open 'https://swoft.org'
172
+ *
173
+ * Linux:
174
+ * x-www-browser 'https://swoft.org'
175
+ *
176
+ * Windows:
177
+ * cmd /c start https://swoft.org
178
+ *
179
+ * @param string $pageUrl
180
+ */
181
+ public static function openBrowser (string $ pageUrl ): void
182
+ {
183
+ if (self ::isMac ()) {
184
+ $ cmd = "open \"{$ pageUrl }\"" ;
185
+ } elseif (self ::isWin ()) {
186
+ // $cmd = 'cmd /c start';
187
+ $ cmd = "start {$ pageUrl }" ;
188
+ } else {
189
+ $ cmd = "x-www-browser \"{$ pageUrl }\"" ;
190
+ }
191
+
192
+ // Show::info("Will open the page on browser:\n $pageUrl");
193
+ self ::execute ($ cmd );
194
+ }
195
+
167
196
/**
168
197
* get screen size
169
198
*
You can’t perform that action at this time.
0 commit comments