Skip to content

Add environment-aware connection methods to Address and Ports contracts.#22

Merged
gustavofreze merged 12 commits intomainfrom
fix/environment-aware-address
Apr 14, 2026
Merged

Add environment-aware connection methods to Address and Ports contracts.#22
gustavofreze merged 12 commits intomainfrom
fix/environment-aware-address

Conversation

@gustavofreze
Copy link
Copy Markdown
Member

No description provided.

…ontracts

Adds getHostForConnection() to Address contract and getPortForConnection() to Ports contract. These methods use HostEnvironment::isInsideDocker() to transparently return the correct host/port for connecting to the container regardless of whether the caller is running inside Docker or on the host.
Added section on environment-aware connection methods for Docker.
Add PHP use imports to all self-contained code examples in README. Make environment-aware connection example self-contained with MySQLDockerContainer setup.
Copilot AI review requested due to automatic review settings April 14, 2026 16:57
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds environment-aware connection helpers to container address/port contracts so callers can automatically choose the correct host/port depending on whether they’re running inside Docker or on the host.

Changes:

  • Extend Contracts\Address and Contracts\Ports with environment-aware connection methods.
  • Implement the new methods in internal Address and Ports models using HostEnvironment::isInsideDocker().
  • Add unit tests (with file_exists overrides) and document usage in the README.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/Contracts/Address.php Adds getHostForConnection() to the public Address contract.
src/Contracts/Ports.php Adds getPortForConnection() to the public Ports contract.
src/Internal/Containers/Address/Address.php Implements environment-aware host selection.
src/Internal/Containers/Address/Ports.php Implements environment-aware port selection.
tests/Unit/Internal/Containers/Address/AddressTest.php Tests host selection inside vs outside Docker.
tests/Unit/Internal/Containers/Address/PortsTest.php Tests port selection inside vs outside Docker.
tests/Unit/Internal/Containers/Overrides/file_exists_inside_docker.php Test override to simulate “inside Docker”.
README.md Documents the new environment-aware connection helpers with examples.

Comment thread src/Internal/Containers/Address/Ports.php Outdated
Comment thread src/Contracts/Ports.php Outdated
Comment thread tests/Unit/Internal/Containers/Address/AddressTest.php Outdated
Comment thread src/Internal/Containers/Address/Address.php Outdated
Comment thread src/Contracts/Ports.php
Comment thread src/Contracts/Ports.php Outdated
Comment thread src/Contracts/Address.php
Comment thread src/Contracts/Address.php
@gustavofreze gustavofreze merged commit 4ab0ee9 into main Apr 14, 2026
5 checks passed
@gustavofreze gustavofreze deleted the fix/environment-aware-address branch April 14, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants