Skip to content

dev-server — Configurable Host Binding #9

@artmuscode

Description

@artmuscode

Problem

Problem

The marko up command starts PHP's built-in server bound to localhost, which only listens on the loopback interface (127.0.0.1). Inside a devcontainer, port forwarding connects to the container's network interface — not its loopback — so requests from the host machine never reach the PHP server.

Proposed Solution

Solution

Added a configurable host option to the dev-server package.

Default config (vendor/marko/dev-server/config/dev.php):

  • Added 'host' => 'localhost' — safe default for local development.

DevUpCommand (vendor/marko/dev-server/src/Command/DevUpCommand.php):

  • Reads host from --host CLI option or dev.host config key.
  • Uses the configured host in the php -S command instead of the hardcoded localhost.

App-level override (config/dev.php):

  • Sets 'host' => '0.0.0.0' so the server listens on all interfaces inside the container.

Usage

For local development (no container), the default localhost binding works as before. For devcontainer environments, override in your app's config/dev.php:

return [
    'host' => '0.0.0.0',
];

Or pass it as a CLI option:

marko up --host=0.0.0.0

Alternatives Considered

Unless, this is possible inside the framework already, I may have overlooked it.

Package

dev-server

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions