-
-
Notifications
You must be signed in to change notification settings - Fork 235
Fix command-line arguments & allow using env vars and wildcard IP addresses for server #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Can you provide the bug fix in a separate PR please? |
| public function waitUntilReady(Process $process, string $url, bool $ignoreErrors = false): void | ||
| public function waitUntilReady(Process $process, string $url): void | ||
| { | ||
| $context = \stream_context_create(['http' => [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change? It will not work if the / route isn't defined for instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it instead uses a socket, I thought it might be a much better idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm 👎 to use a socket. Using a HTTP client ensure that this a HTTP server. (A server supporting another protocol may already use this port).
| while (Process::STATUS_STARTED !== ($status = $process->getStatus()) || false === @\file_get_contents($url, false, $context)) { | ||
| $host = parse_url($url, PHP_URL_HOST); | ||
|
|
||
| if ($host === '0.0.0.0') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use yoda style.
| \usleep(1000); | ||
| } while (Process::STATUS_STARTED !== $status || ++$retries === $maxRetries); | ||
|
|
||
| if (count($socketErrors)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\count()
Using PHP 7.2.2 on Windows, testing this code in the WebServerManager:
And I have this output:
The first one is wrong, so I decided to refactor it with a plain
array_merge()that will surely be working 👍This PR also introduces lots of other changes that allow using env vars and ips like
0.0.0.0for servers listening to any host. I thought it would be a really nice improvement