This document outlines the changes made to upgrade mudCMS from PHP 7.x to PHP 8.2+.
- Before: No explicit PHP version requirement
- After:
php: ^8.2 - Benefit: Access to latest language features, improved performance, better type safety
- Before: PHPUnit 9
- After: PHPUnit 11
- Benefit: Better compatibility with PHP 8.2+, improved testing features
The codebase already uses several PHP 8+ features:
- ✅ Typed properties (e.g.,
private PDO $connin PostRepo) - ✅ Named parameters (PDO parameter binding)
- ✅ Return type declarations (e.g.,
get_total_posts(): int)
PHP 8.2 brings improved type handling with readonly properties and better union types. While these aren't applied yet, they're available for future refactoring.
- 5-10% faster execution than PHP 8.0
- Better memory management
- Improved JIT compilation
- Update PHP requirement in composer.json
- Update PHPUnit to v11
- Verify type declarations are compatible
- Test with PHP 8.2 runtime
- Review deprecated function usage
- Update deployment configurations
The following functions were deprecated in PHP 7.4+ and removed/changing in PHP 8+:
ini_set()- Still supported but consider alternativesinclude()/require()- Still supported, consider autoloading- Session functions - Still supported, but consider modern session handling
-
Replace dynamic includes with autoloading
// Before include("assets/init.php"); // After (with proper composer.json autoloading) use Secret\MudCms\Initialization;
-
Type hints for all functions
// Before public function get_posts_latest($amnt, $offset = 0) // After (PHP 8+) public function get_posts_latest(int $amnt, int $offset = 0): array
-
Named arguments (PHP 8.0+)
// New capability $posts = $postRepo->get_posts_latest(amnt: 10, offset: 0);
- ✅ PDO is fully compatible with PHP 8.2
- ✅ GD extension works perfectly in PHP 8.2
- ✅ All current code is forward-compatible
To test locally:
# Verify PHP version
php -v
# Run composer update
composer update
# Run PHPUnit tests
php vendor/bin/phpunitUpdate your deployment environment:
Docker Example:
FROM php:8.2-apache
RUN docker-php-ext-install pdo pdo_mysql gdSystem Requirements:
- PHP 8.2 or later
- MySQL 5.7+ or MariaDB 10.3+
- Apache 2.4+ with mod_rewrite enabled
Most code remains compatible. Key differences:
- Strict parameter type checking - More enforced
- Removed functions - Already not used in mudCMS
- Error handling - More strict about null safety
- ✅ Update composer.json (COMPLETED)
- Run full test suite on PHP 8.2 environment
- Update CI/CD pipelines to PHP 8.2
- Deploy to staging for validation
- Monitor production for any issues
For questions about PHP 8 features, refer to: