Repository navigation
Separate Composer and PHP development services - #19
Conversation
gachakra
left a comment
There was a problem hiding this comment.
Reviewed 291a52c0e59eb38e91c5278c18576f956fccf8d0. Fresh startup works as intended. I found two issues with the shared image build and the documented failure behavior.
- On Docker Compose v2.40.3, a clean
up -d --build --remove-orphanswaited for Composer to exit 0 before starting PHP. With Composer forced to exit 1,upreturned 1 and left PHP increated. I also verified the manual install and Composer command override. The inline comments contain the rebuild and restart reproductions. - On PHP 8.4.28 and 8.5.13, PHPUnit passed with 345 tests and 1,458 assertions per version. All 25 examples passed with assertions enabled. Composer validation, platform requirements, strict PSR-4 autoloading, PHP lint, and the PHPStan 2.3.7 CI checks passed on both versions. The selection fixture reported its 13 expected existing diagnostics. The Git and Composer distribution archives each matched the expected file list.
- Docker checks ran on Docker Desktop using isolated resource names. Native Linux bind-mount ownership remains unverified.
| - php-enumex | ||
|
|
||
| composer: | ||
| <<: *php-image |
There was a problem hiding this comment.
[P3] Build the shared image from a single service
The anchor gives both services a build and the same output tag. Compose v2.40.3 exports two image IDs with different com.docker.compose.service labels, and repeated builds can leave either ID tagged as php-enumex:local. I reproduced a PHP replacement without touching the Dockerfile by running docker compose build php → docker compose up -d --no-build → docker compose build composer → docker compose up -d --no-build. The last command replaced the running PHP container, interrupting any exec sessions. Give one service ownership of the build and let the other reference the resulting image. I verified that keeping build on composer and setting pull_policy: never on the image-only php service allows a fresh up -d --build with one image ID.
| Wait until the PHP service logs show `Composer installation complete`. On the first run, dependencies may still be installing after the container starts. Press Ctrl+C to stop following the logs (the PHP container remains running), then enter the PHP container and run the example: | ||
| Both services use the same PHP 8.4 CLI image and mount the project directory. The one-shot `composer` service installs the locked development dependencies into the host project's `vendor/` directory, then exits. The `php` service starts after Composer exits successfully and remains available for development. The host IDE and both services see the same installed dependencies. The named `composer-cache` volume retains downloaded package data independently of the installed dependencies. | ||
|
|
||
| An exited Composer service with exit code 0 is expected. If installation fails, inspect `docker compose logs composer`; the dependent PHP service will not start successfully. |
There was a problem hiding this comment.
[P3] Scope the installation failure guarantee to fresh startup
An already-running PHP container stays running if a subsequent up fails to reinstall dependencies. Also, with a broken lock file in a disposable checkout, docker compose restart returned 0 and PHP accepted exec commands even though Composer exited 1. This can make a stale vendor/ look ready after a restart. State that a fresh up waits for a successful installation, and point readers to the explicit docker compose run --rm composer command for dependency resynchronization while PHP is running.
gachakra
left a comment
There was a problem hiding this comment.
Re-reviewed 4ee1bad2bf7e71c4504dae6cb49510ce95288c99. Both prior findings are addressed. I found no additional actionable issues.
- Docker Compose v2.40.3 built one shared image.
docker compose build composerfollowed bydocker compose up -d --no-buildkept the same image ID and running PHP container. A broken lock file blocked PHP on fresh startup. With PHP already running, failed reinstallation andrestartbehaved as the revised README describes. The explicit install returned a failure status, and startup recovered after restoring the lock file. - The coding-style update puts the constructor before static factories and gives normal methods a default order based on responsibility. The guidance preserves cohesive method groups and existing member organization. I checked it against
AGENTS.mdand ran the newCaseLabelsnippet with assertions covering identity, naming, transformation, and string conversion on both supported PHP versions. - PHP 8.4.28 and 8.5.13 each passed 345 PHPUnit tests, 1,458 assertions, all 25 executable examples, and the PHPStan 2.3.7 CI checks. The selection fixture reported the same 13 expected diagnostics on both versions. Composer validation, platform checks, strict PSR-4, PHP lint, and Git and Composer archive checks also passed. Native Linux file ownership remains unverified because the Compose checks ran on Docker Desktop.
Summary
vendor/.This PR is independent of the API changes in #18. No PHP source, Dockerfile, dependencies, or CI configuration changes.
Verification
The existing hosted CI checks the PHP package, not the Compose workflow. A Docker engine is unavailable in the authoring environment; an actual image build and Compose startup/failure-path smoke test remain to be performed during review.