You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I noticed that when I register an observers with the ObservedBy attribute is not tracked by event:list command while via observe method in an AppServiceProvider this is appropriately tracked.
Steps To Reproduce
Create a model with an Observer
Run php artisan event:list command
Check the different behavior based on the register mode
The text was updated successfully, but these errors were encountered:
As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.
If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.
The issue occurs because PHP attributes like ObservedBy are inspected at runtime. Observers registered using attributes are resolved only when the corresponding model is bootstrapped. However, the php artisan event:list command does not bootstrap models, so their observers are not resolved, and related events do not appear in the list.
To include these in php artisan event:list, a mechanism is needed to discover and bootstrap all models in the application. This could be achieved by:
Automatically scanning directories (e.g., app/Models) to locate all model classes.
Explicitly defining a model registry (e.g., in a models.php config file).
Laravel Version
11.33.2
PHP Version
8.2.24
Database Driver & Version
No response
Description
Hi, I noticed that when I register an observers with the
ObservedBy
attribute is not tracked byevent:list
command while via observe method in an AppServiceProvider this is appropriately tracked.Steps To Reproduce
php artisan event:list
commandThe text was updated successfully, but these errors were encountered: