Answer the question
In order to leave comments, you need to log in
How to specify the full path to the class in composer.json?
Example:
There is a global class Test in the vendor/mylib/Test.php folder
In vendor/mylib/composer.json I specified
"autoload": {
"psr-4": {
"Test": "/Test.php"
}
},
Answer the question
In order to leave comments, you need to log in
Because / is an absolute path from the system root
Plus Test is a namespace, not a class. And the output will be Test / Test, and not just Test.
To simply register classes, you need to do something like
"autoload": {
"psr-4": {
"": "src/"
}
},
"autoload": {
"classmap": ["src/"]
}
Good afternoon.
Specify the path where the files are located in composer.json, and write namespace in the files themselves.
For example, there is a core directory where the Test.php class is located.
The core directory and composer.json are on the same level.
So, in composer.json you specify
"autoload": {
"psr-4": {
"app\\": ""
}
}
namespace app\core;
class Test
{
//******
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question