-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patheps
More file actions
51 lines (42 loc) · 1.11 KB
/
eps
File metadata and controls
51 lines (42 loc) · 1.11 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env php
<?php
use Darkterminal\EscposPrinterServer\Server;
require_once __DIR__ . '/vendor/autoload.php';
$host = '0.0.0.0';
$port = 1945;
$logs = __DIR__ . DIRECTORY_SEPARATOR . 'logs';
$args = $argv;
array_shift($args);
$argAndOptions = argv2assoc($args);
foreach ($argAndOptions as $key => $value) {
switch ($key) {
case '--role':
$role = strtolower($value);
break;
case '--host':
case '-h':
$host = $value;
break;
case '--port':
case '-p':
$port = $value;
break;
case '--log-dir':
case '--logs':
case '-l':
$logs = $value;
break;
}
if (in_array($key, ['--host', '-h', '--port', '-p', '--log-dir', '--logs', '-l'])) {
unset($argAndOptions[$key]);
}
}
echo "Starting server on $host:$port" . PHP_EOL;
echo "Logs: $logs" . PHP_EOL;
$server = new Server($host, $port);
$server->setLogDirectory($logs);
match ($role) {
'ws' => $server->runWebSocketOnly(),
'http' => $server->runHttpOnly(),
default => $server->run()
};