typo3/class-alias-loader
Adds Composer-powered class aliasing for PHP libraries that rename classes. Reads alias maps from composer.json, rewrites vendor/autoload.php on dump-autoload, and registers a loader that calls class_alias() so old class names keep working transparently.
config/app.php) without redundancy.vendor/ directory, resolving class name conflicts (e.g., Symfony\Component\Debug\Debug → Symfony\Component\Debug\Debugger).composer.json and alias map files.AppServiceProvider overrides (package cannot alias Facades natively; see Avoid When).bind() or alias() in AppServiceProvider.| Risk Category | Risk Level | Mitigation Strategy |
|---|---|---|
| Autoload Conflicts | High | Test composer dump-autoload --optimize post-integration; backup vendor/autoload.php. |
| Facades/DI Breakage | Medium | Use Facade::alias() in AppServiceProvider for Facade-specific mappings. |
| Namespace Collisions | Medium | Enforce fully qualified names in alias maps (e.g., \App\Old\Class). |
| Composer Plugin Conflicts | Low | Isolate testing in a dedicated branch; avoid other Composer plugins that modify autoload.php. |
| Debugging Complexity | Low | Implement a custom Artisan command to list active aliases. |
| PHP Version Lock-In | Low | Pin to v2.0.1 (bugfixed) or v1.2.2 for legacy PHP support. |
Deprecation Strategy:
Third-Party Dependencies:
Laravel-Specific Needs:
Input::old() → request()->old())? If yes, this package cannot handle it—require AppServiceProvider overrides.Operational Constraints:
composer.json in all environments (dev/staging/prod), or is this blocked by immutable vendor/ policies (e.g., Docker)?bootstrap/app.php overrides) that might conflict with the loader’s autoload.php injection?Performance Impact:
always-add-alias-loader? If yes, measure autoload time in production (should be negligible with opcache).Testing Strategy:
Rollback Plan:
Old\Class → App\New\Class) but cannot replace Laravel’s Facade aliasing or container binding.vendor/ environments.composer.json and autoload maps.Assessment Phase (1–2 weeks):
grep -r "Input::" app/, php artisan vendor:purge).app/Compatibility/LaravelAliasMap.php).Integration Phase (2–3 weeks):
composer.json:
"extra": {
"typo3/class-alias-loader": {
"class-alias-maps": [
"app/Compatibility/LaravelAliasMap.php",
"vendor/symfony/http-foundation/alias-map.php"
],
"always-add-alias-loader": true
}
}
composer install --no-dev and test in a staging environment.vendor/autoload.php includes the loader.new Old\Class() works).composer dump-autoload --optimize).Laravel-Specific Workarounds:
AppServiceProvider:
public function register()
{
Facade::alias('Input', Request::class);
}
bind():
$this->app->bind('Old\Service', function ($app) {
return new App\New\Service();
});
Rollout Phase (1 week):
error_log when old classes are used).| Component | Compatibility Status | Notes |
|---|---|---|
| Laravel Facades | ❌ Not supported | Use AppServiceProvider::alias() instead. |
| Laravel DI Container | ⚠️ Partial | Static aliases bypass DI; use bind() for container-bound services. |
| Symfony/Doctrine | ✅ Full | Ideal for third-party library compatibility. |
| Plain PHP | ✅ Full | Works in any Composer-based PHP project. |
| PHP 8.1+ | ✅ Full | Use v2.0.1 (bugfixed). |
| PHP < 8.1 | ⚠️ Limited | Use v1.2.2 (drops PHP 8.4 support). |
| Case-Insensitive Loading | ❌ Removed (v2.0+) | Use v1.2.2 for legacy support. |
always-add-alias-loader in production until thoroughly tested.How can I help you explore Laravel packages today?