-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Commands discovery in custom namespaces #2840
Comments
I have encountered this problem before with The offending line is line 356: return $className The documentation for the method says that "Find the qualified name of a file according to the namespace of the first matched namespace path.". Since the path In if (empty($className) || ! class_exists($className))
{
continue;
} since the class namespaced with My solution was to change line 356 of // check if the class exists
if (class_exists($className)) {
return $className;
} |
Yes, I think that would do it. Could you send a PR to fix this? |
Okay I'll fork the repo and issue a PR. |
…aced-class-finder Fixed Issue #2840 on discovery of classes by FileLocator
Direction
The order of namespace declaration in
$psr4
array has an impact on a proper discovery of Commands when our package is located somewhere inAPPPPATH
.Initially, I asked this question on the forum but it didn't gain any attention, so decided to post it here as a bug.
Describe the bug
The problem occurs when our module/package is placed somewhere in
APPPATH
with a custom namespace. In that case, we have to keep a "special" order in the$psr4
array in Autoload class. Otherwise, our Commands won't be discovered with a proper namespace and as a result - they won't be accessible at all.So, here is an example with myth-auth package. This won't work:
but this one will:
CodeIgniter 4 version
4.0.2 and dev
Affected module(s)
It affects only
Commands
. Probably it has something to do with the wayFileLocator::findQualifiedNameFromPath()
is working.Expected behavior, and steps to reproduce if appropriate
To a quick reproduction of this bug I used a myth-auth package. I declared a
$psr4
array as follow:Then I tried to run a command:
php spark list
- but no new commands appeared. Also calling any command that supposes to be there directly fails.Commands for this package should be correctly discovered regardless of the order in the
$psr4
array.The text was updated successfully, but these errors were encountered: