VOOZH about

URL: https://deepwiki.com/calevans/staticforge/10.3-migration-patterns

⇱ Migration Patterns | calevans/staticforge | DeepWiki


Loading...
Last indexed: 11 February 2026 (5f6a2a)
Menu

Migration Patterns

Purpose and Scope

This document describes migration strategies and patterns for upgrading StaticForge installations between versions, handling breaking changes, and maintaining backward compatibility. It covers template migrations, configuration updates, PHP version upgrades, and feature compatibility patterns.

For information about testing new versions, see Testing Strategy. For guidance on extending core functionality, see Extending the Core.


Version Upgrade Strategy

StaticForge follows semantic versioning with a multi-layered upgrade approach that prioritizes non-destructive updates and backward compatibility.

Upgrade Process Overview


Migration Workflow:

  1. Version Check: Determine current version using composer show eicc/staticforge
  2. Dependency Update: Modify composer.json version constraint and run composer update
  3. Template Migration: Execute template installer to add new templates without overwriting custom ones
  4. Configuration Audit: Run audit:config to identify missing or deprecated configuration
  5. Configuration Update: Add new required settings to .env and siteconfig.yaml
  6. Build Test: Generate site to verify functionality
  7. Log Review: Check for deprecation warnings and errors

Sources:


Template Migration

The template migration system ensures new templates are installed without destroying user customizations.

Template Installation Script

Diagram: Template Migration Flow


Non-Destructive Installation Pattern:

The template installer implements a copy-if-not-exists pattern that protects user customizations:


This ensures that:

  • New templates from library updates are installed automatically
  • User-customized templates in the project are never overwritten
  • Template updates require manual merging if customizations exist

Context Detection:

The script detects whether it's running in a library installation or project root:

ContextDetection LogicAction
Library Installbasename(dirname(__DIR__)) === 'staticforge' && basename($vendorDir) === 'vendor'Copy templates from vendor to project
Project RootOtherwiseSkip (templates already in place)
Source Path__DIR__ . '/../templates'Library templates directory
Target Pathdirname($vendorDir) . '/templates'Project templates directory

Sources:


Configuration Migration

Configuration migration handles the evolution of environment variables and site configuration structure across versions.

Configuration Resolution Hierarchy

Diagram: Configuration Migration Pattern


Default Fallback Pattern:

The bootstrap implements defensive defaults that ensure backward compatibility:


Migration Strategy:

Configuration ChangeMigration PatternExample
New Required VariableAdd to .env.example, add default in bootstrapLOG_LEVEL defaulting to INFO
New Optional VariableAdd to .env.example only, check before useGOOGLE_ANALYTICS_ID
Renamed VariableSupport both names with deprecation warningRead old name, write to new name
Moved to siteconfig.yamlRead from both sources with priorityTEMPLATE from siteconfig > .env
Removed VariableContinue reading but don't use, log warningDeprecated feature toggles

Sources:


Path Normalization Migration

Path normalization ensures compatibility across different installation contexts and operating systems.

Path Resolution Algorithm

Diagram: Path Normalization Flow


Normalization Implementation:

The path normalization function handles multiple path formats to support migrations across different environments:


Supported Path Formats:

FormatExampleDetectionAction
Unix Absolute/var/www/contentStarts with /Return unchanged
Windows AbsoluteC:\Projects\contentMatches [A-Z]:\Return unchanged
Stream Wrappervfs://test/contentContains ://Return unchanged
Relative PathcontentNone of abovePrepend $appRoot

App Root Discovery:

The bootstrap discovers the application root by traversing up the directory tree:


Sources:


Container Variable Updates

The Container class provides both setVariable and updateVariable methods to support configuration migrations.

Variable Update Patterns

Diagram: Container Variable Migration


Migration Pattern Examples:

ScenarioMethodUse Case
Initial BootstrapsetVariable()Setting configuration from .env during bootstrap
CLI OverrideupdateVariable()Command-line --input or --output options overriding defaults
Feature ConfigurationsetVariable()Feature registering its own variables (fails if conflict)
Test SetupupdateVariable()Tests overriding configuration for isolated testing
Template OverrideupdateVariable()Command-line --template option overriding siteconfig

Usage in Tests:

Tests demonstrate the migration-safe pattern for configuration updates:


Usage in Commands:

The RenderSiteCommand shows runtime configuration override:


Sources:


Feature Compatibility

Features must maintain backward compatibility across versions while supporting new functionality.

Feature Discovery Priority

Diagram: Feature Override Pattern


Priority-Based Override System:

The feature discovery system implements a cascade override pattern:

  1. User Features (Highest Priority)

    • Location: src/Features/
    • Purpose: Project-specific customizations
    • Example: Custom MarkdownRenderer with additional processing
  2. Composer Features (Medium Priority)

    • Location: Third-party packages via composer.json
    • Declaration: "extra": {"staticforge": {"feature": "Vendor\\Feature"}}
    • Purpose: Shared features from packages
  3. Library Features (Lowest Priority)

    • Location: vendor/eicc/staticforge/src/Features/
    • Purpose: Core features shipped with StaticForge

Migration Strategy for Feature Updates:

Update TypeStrategyExample
Core Feature EnhancementUpdate library, user overrides preservedLibrary updates MarkdownRenderer, user version kept if exists
New Optional FeatureAdd to library, auto-discoveredNew ImageOptimizer feature added in v1.20
Breaking Feature ChangeVersion bump, migration guide providedRssFeed signature changes in v2.0
Feature DeprecationMark deprecated, continue working, remove in next majorOldFeature deprecated in v1.18, removed in v2.0

Backward Compatible Feature Pattern:

Features should implement defensive coding for configuration:


Sources:


PHP Version Migration

StaticForge version 1.19.2 requires PHP 8.4+, which represents a major breaking change for existing installations.

PHP 8.4 Migration Requirements

Diagram: PHP Version Upgrade Path


PHP 8.4 Breaking Changes Impact:

PHP FeatureImpactMigration Action
Type DeclarationsStricter type checkingReview all type hints, ensure compatibility
Deprecated FunctionsRemoved deprecated featuresUpdate code using deprecated functions
Error HandlingMore errors elevated to exceptionsAdd try-catch blocks as needed
Array FunctionsModified behaviorTest array manipulation code
String FunctionsChanged string handlingVerify string processing

Composer Constraint Update:


Docker Migration Example:

For containerized deployments, update the PHP version in Dockerfile or docker-compose.yml:


Sources:


Build ID and Cache Busting Migration

The CacheBuster feature demonstrates version-independent state management.

Cache Buster Pattern

Diagram: Build ID Generation Flow


Migration-Safe Implementation:

The CacheBuster feature sets variables early in the lifecycle:


Version Compatibility:

VersionBuild ID FormatContainer VariableTemplate Variable
1.xUnix timestampbuild_id, cache_buster{{ cache_buster }}
2.x (future)Git commit hashbuild_id, cache_buster{{ cache_buster }}

The abstraction through container variables ensures templates and features continue working regardless of the build ID generation strategy.

Sources:


Testing Backward Compatibility

The test suite demonstrates patterns for ensuring backward compatibility during migrations.

Test Environment Isolation

Diagram: Test Configuration Override


Test Isolation Pattern:

Integration tests demonstrate the migration-safe pattern for configuration:


Migration Testing Checklist:

  • Test with empty configuration (all defaults)
  • Test with partial configuration (some values missing)
  • Test with legacy configuration format
  • Test with new configuration format
  • Test configuration override precedence
  • Test directory path variations (absolute, relative, stream wrappers)
  • Test feature discovery with user overrides
  • Test template override resolution

Sources:


Configuration Audit Command

The audit:config command helps identify migration issues.

Configuration Validation Pattern

Diagram: Configuration Audit Flow


Configuration Interface:

Features declare their configuration requirements:


Migration Use Case:

After upgrading StaticForge versions:


Sources:


Recommended Migration Workflow

Step-by-Step Migration Guide

  1. Backup Current Installation

    
    
  2. Check Current Version

    
    
  3. Review Changelog

    • Read CHANGELOG.md for breaking changes
    • Note deprecated features
    • Identify new required configuration
  4. Update Dependencies

    
    
  5. Migrate Templates

    
    
  6. Update Configuration

    
    
  7. Audit Configuration

    
    
  8. Test Build

    
    
  9. Review Output

    
    
  10. Commit Changes

    
    

Sources: