Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[WebServerBundle] Added ability to display the current hostname address if available when binding to 0.0.0.0 #28586

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

Merged
merged 1 commit into from
Oct 10, 2018

Conversation

respinoza
Copy link
Contributor

@respinoza respinoza commented Sep 24, 2018

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? ? (no tests for server commands)
Fixed tickets #28585
License MIT
Doc PR symfony/symfony-docs#...

Tries to get the local hostname into an ip (if available) using the PHP gethostname* methods.

@nicolas-grekas nicolas-grekas changed the title [WebServerBundle] Added ability to display the current hostname addre… [WebServerBundle] Added ability to display the current hostname address if available when binding to 0.0.0.0 Sep 24, 2018
@nicolas-grekas nicolas-grekas added this to the next milestone Sep 24, 2018
/**
* @return string contains resolved hostname if available, empty string otherwise
*/
public function getExtraAddress()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about renaming this method as getRealAddress() or getResolvedAddress() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javiereguiluz will do, it reads better.

$io->success(sprintf('Server listening on http://%s', $config->getAddress()));
$message = sprintf('Server listening on http://%s', $config->getAddress());
if ('' !== $extra = $config->getExtraAddress()) {
$message = sprintf('%s (http://%s)', $message, $extra);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we can hardcode http:// here. What if we are using https:// in the local environment? Maybe it's better to detect that and add it in the getExtraAddress() method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javiereguiluz we assume this as the php server won't support SSL, besides we already assume this in the original message.

$io->success(sprintf('Server listening on http://%s', $config->getAddress()));
$message = sprintf('Server listening on http://%s', $config->getAddress());
if ('' !== $extra = $config->getExtraAddress()) {
$message = sprintf('%s (http://%s)', $message, $extra);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it a bit easier to understand for users, we could change the output from this:

[OK] Server listening on http://0.0.0.0:8080 (http://172.20.0.2:8080)

to something like this:

[OK] Server listening on http://0.0.0.0:8080 (resolved as http://172.20.0.2:8080)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javiereguiluz will do the change as resolved, this should also match the method name change (more consistent)

/**
* @return string contains resolved hostname if available, empty string otherwise
*/
public function getResolvedAddress()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest calling it getDisplayAddress actually (nothing is "resolved" to me)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you recommend to reword the message displayed to users too? Currently it says ... (resolved as ...) I think it's easy to understand that way ... but may there's a better wording. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a suggestion in the issue

[OK] Server listening on all interfaces, port 8080 -- see http://127.0.0.1:8080

@respinoza respinoza force-pushed the debug-server-show-host-too branch from 6417342 to dfd2e8b Compare October 9, 2018 12:01
@respinoza
Copy link
Contributor Author

Updated with the new messages, thanks to @jkufner suggestion, I believe the message now looks cleaner and conveys what we want.

@fabpot
Copy link
Member

fabpot commented Oct 10, 2018

Thank you @respinoza.

@fabpot fabpot merged commit dfd2e8b into symfony:master Oct 10, 2018
fabpot added a commit that referenced this pull request Oct 10, 2018
… hostname address if available when binding to 0.0.0.0 (respinoza)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[WebServerBundle] Added ability to display the current hostname address if available when binding to 0.0.0.0

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | ? (no tests for server commands)
| Fixed tickets | #28585
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

Tries to get the local hostname into an ip (if available) using the PHP gethostname* methods.

Commits
-------

dfd2e8b [WebServerBundle] Added ability to display the current hostname address if available when binding to 0.0.0.0
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.2 Nov 1, 2018
This was referenced Nov 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants