deployment-strategies
Skill4 starsChanged 4 months agoMITView on GitHub
Ship PHP releases with zero downtime — atomic symlink releases, health-gated rollouts, safe database migrations, and fast rollback. Use when the user wants to run database migrations as part of a release without breaking in-flight requests; the user needs to roll back a failed PHP deployment quickly and safely; the user wants to release a new version of a PHP application without dropping requests or serving a maintenance page. Keywords: deployment, zero-downtime, atomic-release, rollback, releases, migrations.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- kid-sid/claude-spellbooktheir own version, first seen Oct 9, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- kid-sid/claude-spellbook★ 190same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository119 other files it gives its agents.
- strategy-bitrix-d7-incrementalSkill
- strategy-explicit-over-magicSkill
- strategy-framework-conventionsSkill
- strategy-legacy-safe-editsSkill
- strategy-minimal-diffSkill
- strategy-no-untested-refactorSkill
- strategy-preserve-public-apiSkill
- strategy-readonly-immutabilitySkill
- strategy-security-firstSkill
- strategy-test-drivenSkill
- openapiSkill
- paginationSkill
- rest-designSkill
- versioningSkill
- cqrsSkill
- dependency-inversionSkill
- hexagonalSkill
- repository-patternSkill
- service-layerSkill
- bitrixSkill
- findings-reportSkill
- laravelSkill
- performanceSkill
- phpSkill
- project-analysisSkill
- refactoringSkill
- roi-prioritizationSkill
- securitySkill
- stack-detectionSkill
- cache-layersSkill
- component-engineSkill
- d7-eventsSkill
- d7-loaderSkill
- d7-orm-queriesSkill
- iblock-elementsSkill
- kernel-main-moduleSkill
- localizationSkill
- controllersSkill
- ormSkill
- validationSkill
- controllersSkill
- query-builderSkill
- routingSkill
- autoload-psr4Skill
- dependency-managementSkill
- scriptsSkill
- connection-poolingSkill
- mysql-indexingSkill
- redisSkill
- transactionsSkill
- ci-github-actionsSkill
- docker-phpSkill
- env-configSkill
- associationsSkill
- entities-mappingSkill
- orm-basicsSkill
- entity-apiSkill
- module-developmentSkill
- routing-controllersSkill
- formsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 6 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 67
Do not apply release strategies when the user only wants to run the application on their own machine.
- Distinctive: line 68
Do not use this skill for provisioning servers, DNS, or cloud infrastructure with Terraform or similar.
- Distinctive: line 92
Keep the last few release directories (or image tags) so rollback is an instant symlink flip or image redeploy, and prune older ones on a …
- Distinctive: line 94
After swapping the release, gracefully reload PHP-FPM (or reset opcache) so workers pick up the new code path instead of serving cached …
- Distinctive: line 96
Before routing traffic, prime opcache and application caches on the new release (a health-check request or a warmup command) so the first …
- Distinctive: line 125
Not applicable — no I/O, auth, or untrusted input.
≈ “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
<!-- generated: do not edit — source: knowledge/atoms/devops/deployment-strategies/ --><!-- schema: atomVersion=3 skillVersion=2 graphVersion=1 --><!-- compile: @php-skills/compiler v1.0.0 (deterministic build) -->PHP Deployment Strategies
When to use
- The user wants to run database migrations as part of a release without breaking in-flight requests.
- The user needs to roll back a failed PHP deployment quickly and safely.
- The user wants to release a new version of a PHP application without dropping requests or serving a maintenance page.
When NOT to use
- Do not apply release strategies when the user only wants to run the application on their own machine.
- Do not use this skill for provisioning servers, DNS, or cloud infrastructure with Terraform or similar.
Core guidance
- Release by atomically swapping a current symlink — Deploy each release into its own timestamped directory, then flip a
currentsymlink to it in one atomic operation rather than editing files in place. - Migrate schema with expand-and-contract, never destructive-in-place — Split schema changes into an expand phase (add nullable columns/tables, deploy code that writes both) and a later contract phase (drop the old shape).
- Deploy an immutable artifact built once — Build one immutable artifact per commit (a container image or a versioned tarball) and promote that exact artifact through staging to production.
Quick recipe
- Copy or extract the immutable artifact into
releases/<timestamp>and run the expand-phase migrations against the shared database. (verify: The new release directory exists and expand migrations applied cleanly) - Warm the new release, hit its health endpoint, and only on success atomically
repoint the
currentsymlink and reload PHP-FPM. (verify: The health check passes andcurrentnow resolves to the new release) - Watch error and latency signals; if healthy, prune old releases and later run
contract migrations, otherwise flip
currentback to the previous release. (verify: Metrics are green and either old releases pruned or rollback completed)
Best practices
- Route traffic to a new release only after a readiness/health endpoint confirms the app booted, connected to its dependencies, and warmed critical caches
- Keep the last few release directories (or image tags) so rollback is an instant symlink flip or image redeploy, and prune older ones on a schedule
- After swapping the release, gracefully reload PHP-FPM (or reset opcache) so workers pick up the new code path instead of serving cached bytecode
- Before routing traffic, prime opcache and application caches on the new release (a health-check request or a warmup command) so the first users do not pay the cold cost
Anti-patterns
| Anti-pattern | Why it fails | Do instead |
| git pull into the live directory | Requests hit a half-updated tree during the transfer, and rollback means another slow, partial sync. | Deploy into a fresh release directory and flip an atomic current symlink once the copy is complete. |
| Routine deploys behind a maintenance page | Scheduled downtime for routine releases erodes availability and discourages frequent, low-risk deploys. | Adopt atomic releases with health-gated cutover so ordinary deploys need no maintenance window. |
| Rebuilding the artifact separately for each environment | Two builds can differ (dependency drift, build-host state), so production runs code that was never tested. | Build one immutable artifact per commit and promote that exact artifact through every environment. |
See references/anti-patterns.md.
Common mistakes
- Dropping a column mid-rollout breaks old workers — Running a destructive migration (drop/rename column) during a rolling deploy breaks the old code still serving traffic. Fix: Use expand-and-contract: add the new shape, deploy dual-writing code, backfill, then drop the old column in a later release once no code references it.
- New code deployed but opcache still serves the old bytecode — After swapping the symlink, opcache with
validate_timestamps=0keeps serving the previous release until FPM reloads. Fix: Reload PHP-FPM (kill -USR2) or reset opcache as the final deploy step, or roll the container so a fresh process loads the new code. - FPM resolves the symlink once and pins the old path — PHP-FPM and opcache can cache the resolved real path of the
currentsymlink, so a swap has no effect until reload. Fix: Reload FPM after every symlink swap, or reference the release directory by its real path in the pool config and reload on deploy.
Version notes
- opcache_reset behavior is unchanged across PHP 7.4 through 8.4 (PHP >=7.4) — The graceful FPM reload signal (
SIGUSR2) andopcache_reset()semantics are stable from PHP 7.4 through 8.4, so the same reload step works across versions.
Security
- Not applicable — no I/O, auth, or untrusted input.
Testing
- Activation and decision behavior are verified in
eval/scenarios/devops/deployment-strategies.yaml.
Additional resources
- references/anti-patterns.md
- references/core.md
- references/examples.md
- references/pitfalls.md
- references/recipes.md
- references/version-differences.md
Knowledge graph
Prerequisites: devops/docker-php
Related: devops/ci-github-actions, devops/docker-php, devops/env-config, laravel/queues
<!-- graph-fragment: graph/fragments/devops/deployment-strategies.yaml -->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.

