fix: [Autoloader] Composer classmap usage#5850
Conversation
MGatner
left a comment
There was a problem hiding this comment.
This is more along the lines of what I expected of the interaction between Autoloader, Composer, and Modules. I'm approving but let's be sure to hear @paulbalandan on this bc I am not entirely sure my understanding was correct. I also have never turned off Composer discovery so I'm not sure what people are expecting from that. Maybe @lonnieezell will have some insight from earlier development of these features?
paulbalandan
left a comment
There was a problem hiding this comment.
I took the time to re-read the thread from my PR up to here and somehow it cleared the misconception I had from reading only the code. I think this approach, coupled with #5849, is better than mine. This PR now syncs the code with the documentation. 👍
Some technical notes:
- I would like the new methods to be internal only (i.e. private) to reduce future BC concerns. And I believe these methods would never be needed to be overridden by users.
- Annoying as it can be, let's just deprecate
discoverComposerNamespaces()instead of removing. We can cleanup in v5.
If we use Compoesr autoloader, the path would be like `/vendor/composer/../../app/Controllers/Home.php`.
Now it always loads and uses Composer classmap if it is available.
7b03571 to
c7e659f
Compare
If we have a lot of Composer packages, and not CodeIgniter packages, Composer discovery needs to look for files in these packages and it find nothing. In that case, if we turn off Composer discovery and set the CodeIgniter Composer package namespaces in the Autoloader Config file, we can avoid the useless Composer discovery. I thought that, but I have never tried yet. |
|
@MGatner @mostafakhudair @paulbalandan I updated all the things, and added changelog. |
MGatner
left a comment
There was a problem hiding this comment.
Thanks all! Great collaboration.
Description
The current implementation uses Composer classmap only when
$modules->discoverInComposeris true.discoverInComposeris the setting for Auto-Discovery within Composer Packages.It has nothing to do with classmap usage.
This PR makes it use always if Composer is available.
Related: #5834
Checklist: