- Can I use this package to migrate deprecated Laravel Facades (e.g., Input::old(), Cache::) without breaking my app?
- No, this package won’t work for Facades due to Laravel’s DI container binding. Use `Facade::alias()` or `AppServiceProvider` for Facade migrations instead. It’s ideal for raw class renames (e.g., `OldClass` → `NewClass`) but avoids Facade/DI conflicts.
- How do I configure class aliases for my Laravel project’s deprecated classes?
- Add a `class-alias-maps` entry in your `composer.json` under `extra` pointing to a PHP file returning an associative array of old→new class names. Example: `"extra": {"typo3/class-alias-loader": {"class-alias-maps": ["app/ClassAliasMap.php"]}}`. Run `composer dump-autoload` to generate aliases.
- Will this work with Laravel’s immutable vendor/ directory (e.g., Docker, CI/CD pipelines)?
- Potentially not—this package modifies `vendor/autoload.php`. Test with `composer dump-autoload --no-scripts` or use the `always-add-alias-loader` flag for runtime-only aliasing. For strict environments, consider manual `class_alias()` calls or Laravel’s native aliasing.
- Does this package support Laravel 11 or newer? Are there PHP version requirements?
- Yes, it works with Laravel 11+ and requires PHP 8.1+ (v1.2.0+). For legacy support (PHP <8.1), use v1.2.2. The package is framework-agnostic but integrates cleanly with Laravel’s Composer autoloading. Test with `composer dump-autoload --optimize` for performance.
- How do I debug or list all active class aliases in my Laravel app?
- Create a custom Artisan command using `ClassAliasMap::getAliasMap()` to dump all aliases. Alternatively, inspect `vendor/autoload.php` after running `composer dump-autoload`. For runtime debugging, enable error reporting to catch alias resolution issues.
- Can I use this for third-party library migrations (e.g., Symfony, Doctrine) in Laravel?
- Absolutely. If a library provides alias maps (e.g., `vendor/library/composer.json`), this package will automatically apply them during `composer dump-autoload`. It’s perfect for migrating Symfony bundles or Doctrine entities without forcing immediate refactoring.
- What’s the rollback strategy if aliases cause issues in production?
- Backup `vendor/autoload.php` before deployment. Pin to v2.0.1 (stable) and revert by removing the `class-alias-maps` entry from `composer.json`, then run `composer dump-autoload`. For Facades or DI-bound services, use Laravel’s native aliasing instead.
- Does this package work with Laravel’s monorepo setups or shared vendor/ environments?
- Yes, it’s designed for shared `vendor/` scenarios. Aliases are globally applied during `composer dump-autoload`, making it ideal for monorepos or multi-project setups where backward compatibility is critical across services.
- How do I handle case-insensitive class loading or PHP <8.1 environments?
- Use v1.2.2 (last version with legacy support) for PHP <8.1. For case-insensitive loading, ensure alias maps use fully qualified names (e.g., `\App\OldClass`). Test thoroughly with `composer dump-autoload --optimize` to catch edge cases.
- What’s the performance impact of using this package in Laravel?
- Minimal overhead—aliases are statically resolved during `composer dump-autoload` and optimized by PHP 8.4+ OPCache. Avoid runtime aliasing (e.g., `ClassAliasMap::addAliasMap()`) for production; pre-define all aliases in `composer.json` for best performance.