I use the following composer.json configs to use phpunit:
{
"require-dev": {
"phpunit/phpunit": "^9"
},
"autoload": {
"psr-4": {
"App\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests"
}
}
}
My project files are as follows:
> src
> Configs
> DB
> Helper
Config.php
> tests
> vendor
composer.json
composer.lock
This error will be thrown as long as "App\\": "src"
in composer.json:
Uncaught Error: Class 'App\Helper\Config' not found in
But if I change the src to app (in composer.json)
and rename the src directory to app, the problem is solved. That is, the composer file should look like this:
{
"require-dev": {
"phpunit/phpunit": "^9"
},
"autoload": {
"psr-4": {
"App\\": "app" // ** rename src to app **
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests"
}
}
}
And arrange directories and files as follows:
> app
> Configs
> DB
> Helper
Config.php
> tests
> vendor
composer.json
composer.lock
What could be the cause of this problem?