Skip to content

Add the possibility to bind ServeCommand to all interfaces - #871

Merged
giuscris merged 2 commits into
2.xfrom
feature/improved-serve-command
Aug 19, 2026
Merged

Add the possibility to bind ServeCommand to all interfaces#871
giuscris merged 2 commits into
2.xfrom
feature/improved-serve-command

Conversation

@giuscris

@giuscris giuscris commented Mar 1, 2026

Copy link
Copy Markdown
Member

This pull request improves the usability of the ServeCommand by making it easier to bind the server to all network interfaces and providing clearer feedback when running in this mode. The changes also enhance the output by listing accessible remote addresses when the server is bound to a wildcard host.

Usability improvements:

  • The default host for the server has been changed from '127.0.0.1' to 'localhost', and new constants LOOPBACK_HOSTS and WILDCARD_HOSTS have been introduced to clarify host types.
  • The host argument description now explains that omitting the value will bind the server to all interfaces.
  • Argument parsing allows --host to be passed without a value, causing the server to bind to all interfaces (0.0.0.0).

Output enhancements:

  • When the server is bound to a wildcard host, the output now displays remote addresses for all local network IPs, making it easier for users to find the correct address for remote access.
  • A new helper method getLocalNetworkIps() was added to retrieve local network IP addresses, excluding loopback interfaces.

@giuscris giuscris added this to the 2.4.0 milestone Mar 1, 2026
@giuscris
giuscris requested a review from Copilot March 1, 2026 20:59
@giuscris giuscris self-assigned this Mar 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the ServeCommand developer server CLI to make it easier to bind to all network interfaces and to improve the startup output when running on a wildcard bind address.

Changes:

  • Changed the default bind host from 127.0.0.1 to localhost, and introduced LOOPBACK_HOSTS / WILDCARD_HOSTS constants to classify hosts.
  • Added support for passing --host without a value to bind to all interfaces (intended to map to 0.0.0.0).
  • When bound to a wildcard host, the command now prints “Remote address” URLs for detected local network IPv4 addresses.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread formwork/src/Commands/ServeCommand.php Outdated
Comment thread formwork/src/Commands/ServeCommand.php
@giuscris
giuscris force-pushed the feature/improved-serve-command branch from ba9ca38 to 3dda92c Compare August 19, 2026 12:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (1)

formwork/src/Commands/ServeCommand.php:105

  • The argv rewrite for --host will also trigger when the user passes a host value as a separate argument (e.g. --host 127.0.0.1). In that case the code overwrites the option to 0.0.0.0 and leaves the original host value as a stray positional argument, which is likely to break CLImate parsing or produce unexpected behavior.
        // --host without a value binds to all interfaces
        foreach (array_keys($argv, '--host', true) as $key) {
            $argv[$key] = '--host=0.0.0.0';
        }

@giuscris
giuscris merged commit 3d5cc1d into 2.x Aug 19, 2026
2 checks passed
@giuscris
giuscris deleted the feature/improved-serve-command branch August 19, 2026 12:44
@giuscris giuscris added the cli label Aug 21, 2026
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.

2 participants