-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflow
More file actions
36 lines (29 loc) · 1 KB
/
flow
File metadata and controls
36 lines (29 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env php
<?php
// ANSI colors
$colors = [
'green' => "\033[32m",
'yellow' => "\033[33m",
'blue' => "\033[34m",
'red' => "\033[31m",
'reset' => "\033[0m"
];
// type "php flow ser"
$command = $argv[1] ?? null;
switch ($command) {
case 'ser':
$host = 'localhost';
$port = '2002';
$entry = 'index.php';
echo "{$colors['green']}🚀 Starting PHP server at {$colors['blue']}http://$host:$port{$colors['reset']}\n";
echo "{$colors['yellow']}⏹ Press Ctrl+C to stop the server.{$colors['reset']}\n\n";
// Detect OS to redirect stderr properly
$isWindows = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
$redirect = $isWindows ? '2>nul' : '2>/dev/null';
passthru("php -S $host:$port $entry $redirect");
break;
default:
echo "{$colors['red']}❌ Unknown command: {$colors['yellow']}$command{$colors['reset']}\n";
echo "{$colors['blue']}📘 Usage: php flow ser{$colors['reset']}\n";
break;
}