1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: Donii Sergii <[email protected]> |
5
|
|
|
* Date: 11/3/17 |
6
|
|
|
* Time: 6:08 PM |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace sonrac\WAMP\Commands; |
10
|
|
|
|
11
|
|
|
use Monolog\Formatter\LineFormatter; |
|
|
|
|
12
|
|
|
use Monolog\Handler\StreamHandler; |
|
|
|
|
13
|
|
|
use Monolog\Logger as MonologLogger; |
|
|
|
|
14
|
|
|
use Thruway\Logging\ConsoleLogger; |
15
|
|
|
use Thruway\Logging\Logger; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @trait WAMPCommandTrait |
19
|
|
|
* |
20
|
|
|
* @author Donii Sergii <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
trait WAMPCommandTrait |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* WAMP router host. |
26
|
|
|
* |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
protected $host = '127.0.0.1'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Wamp realm to used. |
33
|
|
|
* |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
protected $realm; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* WAMP router port. |
40
|
|
|
* |
41
|
|
|
* @var int |
42
|
|
|
*/ |
43
|
|
|
protected $port = '9090'; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Run in debug mode. Echo output to console. |
47
|
|
|
* |
48
|
|
|
* @var bool |
49
|
|
|
*/ |
50
|
|
|
protected $noDebug = false; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Run in loop or once. |
54
|
|
|
* |
55
|
|
|
* @var bool |
56
|
|
|
*/ |
57
|
|
|
protected $runOnce = false; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Specify the router protocol as wss. |
61
|
|
|
* |
62
|
|
|
* @var bool |
63
|
|
|
*/ |
64
|
|
|
protected $tls = false; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* WAMP routes path. |
68
|
|
|
* |
69
|
|
|
* @var string |
70
|
|
|
* |
71
|
|
|
* @author Donii Sergii <[email protected]> |
72
|
|
|
*/ |
73
|
|
|
protected $routePath = null; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Transport provider class. |
77
|
|
|
* |
78
|
|
|
* @var string|\Thruway\Transport\RatchetTransportProvider|null |
79
|
|
|
* |
80
|
|
|
* @author Donii Sergii <[email protected]> |
81
|
|
|
*/ |
82
|
|
|
protected $transportProvider = 'Thruway\Transport\RatchetTransportProvider'; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Get option value from input. |
86
|
|
|
* |
87
|
|
|
* @param string $optionName |
88
|
|
|
* |
89
|
|
|
* @return array|null|string |
90
|
|
|
*/ |
91
|
|
|
protected function getOptionFromInput(string $optionName, $default = null) |
92
|
|
|
{ |
93
|
|
|
if (null === $this->input->getOption($optionName)) { |
|
|
|
|
94
|
|
|
return $default; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
return $this->option($optionName); |
|
|
|
|
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Get minion config. |
102
|
|
|
* |
103
|
|
|
* @param string|null $optName Option name |
104
|
|
|
* @param mixed $default Default value |
105
|
|
|
* |
106
|
|
|
* @return array|string|int|null |
107
|
|
|
*/ |
108
|
|
|
protected function getConfig($optName = null, $default = null) |
109
|
|
|
{ |
110
|
|
|
$options = config('minion') ?? []; |
|
|
|
|
111
|
|
|
|
112
|
|
|
if (null === $optName) { |
113
|
|
|
return $options ?? []; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
return isset($options[$optName]) ? $options[$optName] : $default; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Change WAMP logger |
121
|
|
|
* |
122
|
|
|
* @param string $fileName |
123
|
|
|
* |
124
|
|
|
* @author Donii Sergii <[email protected]> |
125
|
|
|
*/ |
126
|
|
|
protected function changeWampLogger($fileName = 'wamp-server.log') |
127
|
|
|
{ |
128
|
|
|
|
129
|
|
|
if (!$this->noDebug) { |
130
|
|
|
return; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
$path = $this->getConfig('pathLogFile') ?? storage_path('logs/' . $fileName); |
|
|
|
|
134
|
|
|
|
135
|
|
|
$handler = (new StreamHandler($path, MonologLogger::DEBUG)) |
136
|
|
|
->setFormatter(new LineFormatter(null, null, true, true)); |
137
|
|
|
|
138
|
|
|
$logger = new MonologLogger($fileName, [$handler]); |
139
|
|
|
|
140
|
|
|
Logger::set($logger); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Parse base options |
145
|
|
|
* |
146
|
|
|
* @author Donii Sergii <[email protected]> |
147
|
|
|
*/ |
148
|
|
|
protected function parseBaseOptions() |
149
|
|
|
{ |
150
|
|
|
$this->host = $this->getOptionFromInput('host') ?? $this->getConfig('host', $this->host); |
|
|
|
|
151
|
|
|
$this->port = $this->getOptionFromInput('port') ?? $this->getConfig('port', $this->port); |
|
|
|
|
152
|
|
|
$this->realm = $this->getOptionFromInput('realm') ?? $this->getConfig('realm', $this->realm); |
|
|
|
|
153
|
|
|
$this->tls = $this->getOptionFromInput('tls') ?? $this->getConfig('tls', $this->tls); |
154
|
|
|
$this->transportProvider = $this->getOptionFromInput('transport-provider') ?? $this->getConfig('transportProvider', |
|
|
|
|
155
|
|
|
$this->transportProvider); |
156
|
|
|
|
157
|
|
|
$this->noDebug = $this->getOptionFromInput('no-debug') ?? $this->noDebug; |
|
|
|
|
158
|
|
|
$this->runOnce = $this->getOptionFromInput('no-loop') ?? $this->runOnce; |
|
|
|
|
159
|
|
|
|
160
|
|
|
$this->routePath = $this->getOptionFromInput('route-path') ?? $this->getConfig('routePath', $this->routePath); |
|
|
|
|
161
|
|
|
$this->routePath = is_string($this->routePath) ? realpath($this->routePath) : null; |
162
|
|
|
|
163
|
|
|
if (!$this->noDebug) { |
164
|
|
|
Logger::set(new ConsoleLogger()); |
165
|
|
|
} |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* Parse input options |
170
|
|
|
* |
171
|
|
|
* @return mixed |
172
|
|
|
* |
173
|
|
|
* @author Donii Sergii <[email protected]> |
174
|
|
|
*/ |
175
|
|
|
abstract protected function parseOptions(); |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Get transport provider |
179
|
|
|
* |
180
|
|
|
* @return mixed |
181
|
|
|
* |
182
|
|
|
* @author Donii Sergii <[email protected]> |
183
|
|
|
*/ |
184
|
|
|
abstract protected function getTransportProvider(); |
185
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths