Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6780581

Browse files
committed
update some for sys command
1 parent 455eb02 commit 6780581

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

‎src/Proc/ProcWrapper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use function fclose;
1616
use function proc_open;
1717
use function stream_get_contents;
18+
use const DIRECTORY_SEPARATOR;
1819

1920
/**
2021
* Class ProcFuncWrapper
@@ -223,7 +224,7 @@ public function open(): self
223224
$options = $this->options;
224225

225226
$options['suppress_errors'] = true;
226-
if ('\\' === \DIRECTORY_SEPARATOR) {
227+
if ('\\' === DIRECTORY_SEPARATOR) {// windows
227228
$options['bypass_shell'] = true;
228229
}
229230

‎src/Sys.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,35 @@ public static function getOutsideIP(): string
164164
return 'unknown';
165165
}
166166

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+
167196
/**
168197
* get screen size
169198
*

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /