symfony/class-loader
Legacy Symfony component providing class loading utilities, including a PSR-4/PSR-0 compatible ClassLoader and related helpers. Used to register autoloaders and find classes in older Symfony/PHP projects; largely superseded by Composer autoloading.
vendor/composer/autoload.php) and PSR-4 standards, making this package redundant for new projects.ClassLoader (via Illuminate\Contracts\Container) or Composer’s autoloader are superior choices.app.php to use Symfony\Component\ClassLoader\ClassLoader.Illuminate vs. Symfony’s Symfony).| Risk Area | Severity (Legacy Laravel) | Severity (Modern Laravel) | Mitigation |
|---|---|---|---|
| Autoloading Conflicts | Medium | Critical | Use composer dump-autoload to sync; avoid mixing with PSR-4. |
| Performance Overhead | Low | High | Symfony’s loader is less optimized than Composer’s. |
| Deprecation Warnings | High | Critical | Suppress deprecation warnings (not ideal long-term). |
| Namespace Pollution | Medium | High | Isolate in a custom namespace; avoid App\ or Illuminate\. |
| Composer Cache Issues | Medium | Medium | Clear Composer cache (composer clear-cache) post-integration. |
| Laravel Core Overrides | Critical | Critical | Requires deep knowledge of Laravel’s bootstrapping process. |
composer dump-autoload --optimize instead.composer require symfony/class-loader:^5.4).composer.json, app.php).bootstrap/autoload.php.app.php:
$loader = new Symfony\Component\ClassLoader\ClassLoader();
$loader->register();
$loader->addPrefixes(array(
'App' => __DIR__.'/app',
));
composer.json to avoid conflicts:
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": []
}
composer dump-autoload --no-scripts.README.md.app.php and run composer dump-autoload).App\Dynamic\) to avoid collisions with Laravel/Symfony.bootstrap/cache/ is writable.| Phase | Task | Owner |
|---|---|---|
| Pre-Integration | Backup app.php and composer.json. |
Developer |
| Integration | Replace autoloader and configure Symfony’s loader. | TPM/Developer |
| Testing | Test dynamic loading, facades, and service providers. | QA/Developer |
| Optimization | Benchmark performance (if needed). | Performance |
| Documentation | Update runbooks for rollback and maintenance. | TPM |
| Deprecation Plan | Schedule removal if using for temporary needs. | TPM/Product |
ClassLoader interface or runtime class generation (e.g., eval with file_get_contents + create_function).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Autoloader Conflict | Fatal errors on class resolution. | Rollback to Composer’s autoloader. |
| Deprecation Warnings | Log pollution; potential future breaks. | Suppress warnings (temporarily). |
| Cache Corruption | Missing classes at runtime. | Clear bootstrap/cache/ and rerun. |
| PHP Version Incompatibility | Loader fails on PHP 8.x. | Pin to PHP 7.4 in composer.json. |
| Dynamic Loading Failure | Classes not found at runtime. | Add debug logs to Symfony’s loader. |
CONTRIBUTING.md.How can I help you explore Laravel packages today?