php-docker-upgrade
Skill0 starsChanged 24 days agoMITView on GitHub
Bump the PHP version of a Dockerized, Makefile-driven project (e.g. a Drupal site) to a target version — 8.4, 8.5 or later. Use when the user mentions upgrading PHP in Docker, changing the PHP base image / Dockerfile version, a "platform.php" constraint, or needs a newer PHP for a framework upgrade (e.g. PHP 8.4 required by Drupal 11). Covers locating the image, bumping it, rebuilding containers, verifying, and updating the Composer platform pin. IMPORTANT: all build commands MUST go through Makefile targets, never run directly on the host.
- Installs packages
In this repository17 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- d11Skill
- drupal-build-foundationsSkill
- drupal-build-intakeSkill
- drupal-buildSkill
- drupal-build-unitSkill
- drupal-rgaaSkill
- drupal-scaffoldSkill
- gulp-to-viteSkill
- jquery-4-migrationSkill
- lando-to-dockerSkill
- phpcbfSkill
- phpcsSkill
- php-deprecations-auditSkill
- php-standardsSkill
- phpstanSkill
- sass-migratorSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 25
If the caller (e.g. the d11 orchestrator) already fixed the target, use it.
- Distinctive: line 93
If the image comes from a tag in compose:
- Very specific: line 100
Verify the PHP extensions installed in the Dockerfile are compatible with the target version (usually yes — double-check pecl / …
- Very specific: line 128
If Composer complains about a frozen platform.php constraint in composer.json, update it to the target version:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
PHP version upgrade in a Docker environment
Bump the PHP runtime of the containers to a target version BEFORE touching
the framework/core — otherwise composer update fails or the site won't boot.
Target version is a parameter. Set <PHP_VERSION> to what you need:
- Drupal 11 → 8.4 (current requirement)
- Future majors (e.g. Drupal 12) → 8.5+ — the procedure is identical, only the number changes.
If the caller (e.g. the d11 orchestrator) already fixed the target, use it.
Otherwise run step 0 to decide whether a bump is needed, and to which version.
0. Check whether a bump is needed
Collect the five facts, then decide:
grep -rhoE 'FROM php:[0-9.]+[^ ]*' docker/ # 1. current image
make composer c='show --self --format=json' | grep -A3 '"requires"' # 2a. the project's "php" constraint
grep -o '"php": *"[^"]*"' web/core/composer.json # 2b. the framework floor (Drupal core)
grep -nE '^image:|php-[0-9.]+' .gitlab-ci.yml # 4. the CI image
curl -s https://endoflife.date/api/php.json | # 3. support cycles
python3 -c "import json,sys;[print(c['cycle'],'eol',c['eol'],'latest',c['latest']) for c in json.load(sys.stdin)[:5]]"- The production runtime (FPM, not only the CLI): ask the user, or read it
from the deploy recipe (e.g. a pinned
bin/php). Never SSH to find out.
| Situation | Decision |
The current cycle is past eol, or below the framework floor | Bump to the newest cycle that the framework supports and production can run; production goes in the MR's prerequisites |
| The current cycle = production's, and a newer cycle is supported but production is still behind | No bump. Report the newer cycle as a follow-up: local must not run ahead of prod |
| Production / CI already moved to a newer cycle | Bump to match them |
| The current cycle = production = CI, and it is supported | Nothing to do. Say so, and still refresh the patch release: make rebuild-no-cache pulls the latest x.y image |
The framework's supported range comes from its docs (Drupal:
drupal.org/docs/getting-started/system-requirements/php-requirements), not from
the floor in composer.json alone. Report the five facts and the decision
before touching any file.
Golden rule: everything goes through the Makefile
This project is Dockerized and driven by a Makefile. Never call composer,
php or docker directly on the host — use the make targets:
| Need | Make target |
| Rebuild images (with cache) | make rebuild |
| Rebuild without cache | make rebuild-no-cache |
| Shell in the PHP container | make shell |
| Composer install + npm install | make install |
| Generic Composer | make composer <args> |
| Drush status | make drush c='status' |
1. Locate the Dockerfile / PHP image
The image is defined either in a dedicated Dockerfile or in
docker-compose.yml.
grep -rn 'php:' docker/ 2>/dev/null
grep -rn 'FROM php' docker/ 2>/dev/null
find . -name 'Dockerfile*' -not -path './vendor/*' -not -path './node_modules/*'2. Update the PHP version
In the PHP service Dockerfile, replace the base image version:
# BEFORE
FROM php:8.3-fpm
# AFTER — <PHP_VERSION>, e.g. 8.4
FROM php:8.4-fpmIf the image comes from a tag in compose:
# docker-compose.yml — php service
image: myregistry/php:8.4-fpm # instead of 8.3Verify the PHP extensions installed in the Dockerfile are compatible with the
target version (usually yes — double-check pecl / docker-php-ext-* calls).
3. Rebuild and restart
make rebuild # rebuild images and restart (with cache)
make rebuild-no-cache # if the PHP layer doesn't refresh4. Verify the new version
make shell
# inside the container:
php -v # should display <PHP_VERSION>.x
exit
# or via drush
make drush c='status' | grep -i php5. Reinstall dependencies under the new PHP
make install # composer install + npm installIf Composer complains about a frozen platform.php constraint in
composer.json, update it to the target version:
"config": {
"platform": {
"php": "8.4.0"
}
}then make composer update --lock.
Where this fits in a framework upgrade
The PHP bump is a technical prerequisite, done first. For a full Drupal
10 → 11 upgrade it is step 2, followed by fixing deprecations and jQuery while
still on D10, then the core bump last — see the d11 orchestrator skill.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

