Open abdokouta opened 1 month ago
Thanks for opening the issue. Could you try the following?
1. Comment the listener registration in olvlvl/composer-attribute-collector/src/Plugin.php
:
public static function getSubscribedEvents(): array
{
return [
// 'post-autoload-dump' => 'onPostAutoloadDump',
];
}
2. Add the plugin after your autoload registration:
"scripts": {
"post-autoload-dump": [
"@php artisan autoload",
"olvlvl\ComposerAttributeCollector\Plugin::onPostAutoloadDump"
]
}
Bug Report
Package:
olvlvl/composer-attribute-collector
Issue Summary
The
Plugin
class fromolvlvl/composer-attribute-collector
loads before my custom autoload logic, which registers classes dynamically. As a result, classes that should be available during the autoload process are not found, leading to undefined class errors.I have a custom command (
php artisan autoload
) that is responsible for loading additional classes after thepost-autoload-dump
event. However, since thePlugin
class registers its autoload mappings first, my classes are not recognized when thecomposer-attribute-collector
runs.Steps to Reproduce
Define a custom autoloading command (
php artisan autoload
) that dynamically loads classes after thepost-autoload-dump
event.Configure
olvlvl/composer-attribute-collector
with the following incomposer.json
:Run
composer dump-autoload
or any related command.Observe that classes expected by my command are not loaded, resulting in class not found errors.
Expected Behavior
The
Plugin
class fromolvlvl/composer-attribute-collector
should allow custom autoload logic to run before it attempts to register classes, or provide a way to delay its execution until after my custom autoload process has completed.Actual Behavior
The
Plugin
class is executed first, which results in classes being unavailable for the autoload process, leading to undefined class errors.Environment
olvlvl/composer-attribute-collector
version: @latestPossible Solution
Allow the
Plugin
class to be manually triggered after custom autoload logic is executed, or provide a configuration option to defer its execution until after custom autoload registration is complete.Additional Context
I currently run a custom command (
php artisan autoload
) in thepost-autoload-dump
section ofcomposer.json
:However, the
Plugin
class runs too early, preventing my autoload command from functioning properly.