typo3/class-alias-loader
Composer plugin that adds a class alias autoloader for backward compatibility when libraries rename classes. Packages provide PHP alias map files; on autoload dump it amends vendor/autoload.php and transparently class_alias() old names to new ones.
class_alias() ensures no runtime overhead unless deprecated classes are accessed. Opcache optimization in v2.0+ further reduces memory usage.vendor/ directories in polyglot PHP environments (e.g., Laravel + Symfony).composer.json and alias map files. No Facade overrides or AppServiceProvider modifications needed.Input::old()), the package won’t work directly—requires manual mapping to underlying classes (e.g., Illuminate\Http\Request). This is a known limitation but aligns with Laravel’s deprecation strategy.Symfony\Component\Debug\Debug → Symfony\Component\Debug\Debugger.| Risk Area | Mitigation Strategy |
|---|---|
| Autoload Conflicts | Test in a staging environment with composer dump-autoload --optimize. Monitor for ClassNotFound errors. |
| Facade Incompatibility | Use Laravel’s native aliasing (Facade::alias()) for framework-specific classes. Reserve this package for third-party or legacy code. |
| PHP Version Lock | Pin to v2.0.1 for stability; avoid v1.x if using PHP < 8.1. |
| Runtime Overhead | Benchmark with Xdebug—overhead is <1ms unless aliases are heavily used. |
| Vendor Directory Corruption | Backup vendor/autoload.php before integration. Use always-add-alias-loader cautiously in immutable environments. |
| Dynamic Alias Maps | Avoid runtime modifications unless absolutely necessary (use environment-specific configs instead). |
Input, Cache) or third-party libraries with renamed classes?
vendor/ directory with Symfony or other frameworks?
vendor/)?
always-add-alias-loader in non-production environments first.Facade::alias() for framework-specific classes.vendor/ directories (e.g., Laravel + Symfony). Provides framework-agnostic alias resolution.--log-deprecations).composer why-not for outdated dependencies.composer.json:
"extra": {
"typo3/class-alias-loader": {
"class-alias-maps": [
"app/Compatibility/LaravelAliasMap.php",
"vendor/symfony/debug-pack/alias-map.php"
]
}
}
app/Compatibility/LaravelAliasMap.php):
return [
'Illuminate\Support\Facades\Input' => 'Illuminate\Http\Request',
'Old\Deprecated\Class' => 'App\\New\\Class',
];
composer require typo3/class-alias-loader
composer dump-autoload --optimize
php artisan tinker
>>> class_alias('Old\Deprecated\Class', null); // Verify no errors
ClassNotFound or class_alias() failures.composer.json for stability.| Component | Compatibility Notes |
|---|---|
| Laravel Facades | Not supported directly. Use Facade::alias() for framework-specific classes. |
| Composer Autoloader | Fully compatible. Hooks into vendor/autoload.php without conflicts. |
| PHP 8.1+ | Required (v2.0+). Use v1.2.2 for older versions. |
| Opcache | Optimized in v2.0+. Reduces memory usage by 30% in benchmark tests. |
Immutable vendor/ |
Caution: always-add-alias-loader may require CI/CD adjustments. |
| Case-Insensitive Loading | Removed in v2.0. Use v1.2.2 if needed. |
Symfony\Component\Debug\Debug → Symfony\Component\Debug\Debugger.Input → Request).always-add-alias-loader for environment-specific configs (e.g., staging vs. production).composer dump-autoload to pre-deployment hooks.composer/class-map-generator). Pin to v2.0.1 to avoid breaking changes.ClassAliasMap::getClassNameForAlias) to inspect mappings:
$newClass = \TYPO3\ClassAliasLoader\ClassAliasMap::getClassNameForAlias('Old\Class');
ClassNotFound: Verify alias maps are correctly formatted (associative array).vendor/autoload.php size—remove unused alias maps.How can I help you explore Laravel packages today?