Answer the question
In order to leave comments, you need to log in
Why doesn't PHP see the parent class when using the Composer class autoloader?
I have a project, here is its structure:
I, accordingly, used Composer to autoload classes, I registered this in cmposer.json:
"autoload":
{
"psr-4":
{
"core\\": "core",
"application\\controllers\\": "controllers",
"application\\models\\": "models",
"application\\views\\": "views"
}
}
namespace application\models;
require_once __DIR__.'/../../vendor/autoload.php';
class Model
{
}
namespace application\models;
require_once __DIR__.'/../../vendor/autoload.php';
class AuthModel extends Model
{
}
Fatal error: Class 'application\models\Model' not found in D:\prog\openserv\OpenServer\domains\test.dev\application\models\authmodel.php on line 7
Answer the question
In order to leave comments, you need to log in
1. Character case matters.
2. You don't need to include an autoloader in every file. This is done once, at the entry point.
3. Why so much garbage in the autoloader configuration?
It is enough to specify the root namespace.
"psr-4":
{
"core\\": "core",
"application\\": "application",
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question