Add environment-aware connection methods to Address and Ports contracts.#22
Merged
gustavofreze merged 12 commits intomainfrom Apr 14, 2026
Merged
Add environment-aware connection methods to Address and Ports contracts.#22gustavofreze merged 12 commits intomainfrom
gustavofreze merged 12 commits intomainfrom
Conversation
…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.
There was a problem hiding this comment.
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\AddressandContracts\Portswith environment-aware connection methods. - Implement the new methods in internal
AddressandPortsmodels usingHostEnvironment::isInsideDocker(). - Add unit tests (with
file_existsoverrides) 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.