Automated Legacy PHP Modernizer & Code Migrator upgrading PHP 5.x / 7.x procedural patterns and
mysql_*to modern PDO and PHP 8.4+. Built with zero external dependencies.
flowchart TD
A["Legacy PHP Codebase\n(PHP 5.x / 7.x)"] --> B["eidcloud-modernize CLI"]
B --> C{"AST & Token Parser"}
C --> D1["mysql_* ➔ PDO Statements"]
C --> D2["function ClassName() ➔ __construct()"]
C --> D3["Untyped Properties ➔ Constructor Promotion"]
C --> D4["ereg_* / split() ➔ preg_* / explode()"]
C --> D5["while(each()) ➔ foreach()"]
C --> D6["isset() ? : ➔ Null Coalescing ??"]
C --> D7["switch ➔ match Expressions"]
D1 & D2 & D3 & D4 & D5 & D6 & D7 --> E["Unified Diff Generator"]
E --> F["Automated Syntax Validation\n(php -l check)"]
F --> G{"Execution Mode"}
G -->|"--dry-run"| H["Colorized Terminal Diff Preview"]
G -->|"--apply --backup"| I["Create .bak & Write Modern PHP 8.4+ Code"]
| Legacy Pattern (PHP 5.x / 7.x) | Modernization Target (PHP 8.2 - 8.4+) | Transformer Engine |
|---|---|---|
mysql_connect(), mysql_query() |
new \PDO(), PDOStatement prepared calls |
MysqlToPdoTransformer |
function ClassName() |
public function __construct() |
ConstructorTransformer |
var $prop; $this->prop = $prop; |
Constructor Property Promotion public $prop |
PropertyPromotionTransformer |
ereg(), eregi(), ereg_replace() |
preg_match(), preg_replace() |
EregToPregTransformer |
split(',', $str) |
explode(',', $str) / preg_split() |
EregToPregTransformer |
while(list($k,$v) = each($arr)) |
foreach ($arr as $k => $v) |
EachToForeachTransformer |
isset($x) ? $x : $default |
$x ?? $default |
NullCoalescingTransformer |
switch ($v) { case: return ... } |
return match ($v) { ... } |
MatchExpressionTransformer |
Clone the repository or install via Composer:
git clone https://github.com/mhdshadi/eidcloud-php-modernizer.git
cd eidcloud-php-modernizerOr require via Composer:
{
"require": {
"eidcloud/php-modernizer": "^1.0"
}
}The modernized executable is located at bin/eidcloud-modernize:
php bin/eidcloud-modernize scan ./legacy_project/php bin/eidcloud-modernize upgrade ./legacy_project/ --dry-runphp bin/eidcloud-modernize upgrade ./legacy_project/ --apply --backupphp bin/eidcloud-modernize --helpeidcloud-php-modernizer comes equipped with a 100% zero-dependency automated test runner:
php tests/run_tests.phpAll unit tests validate AST transformations, diff generation, and verify compilation using native php -l.
Eng. MHD. Shadi AL-Hasan
EidCloud Architecture & Modernization Systems
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright (c) 2026 MHD. Shadi AL-Hasan.
Eng. MHD. Shadi AL-Hasan
- Role: Executive CTO & Enterprise Solutions Architect
- Email: mhd.shadi.alhasan@gmail.com
- Phone / WhatsApp: +963934005922
- Location: Damascus, Syria
- GitHub: shadialhasan
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright (c) 2026 MHD. Shadi AL-Hasan. All rights reserved.