I am using the ps-4 autoloader using Composer.
"autoload": {
"psr-4": {
"App\\":"app/",
"Database\\":"database/"
}
},
So, I have the main index.php file in the root directory like this
require 'vendor/autoload.php';
use App\Server;
$server = new Server();
The root directory has the app folder and a class called Server in it like this
namespace App;
echo "in server<hr>";
class Server{}
I get the echo "in server" so the class file gets included. But I get this error
Fatal error: Uncaught Error: Class "App\Server" not found in /var/www/html/index.php:8 Stack trace: #0 {main} thrown in /var/www/html/index.php on line 8
It looks for a class called "App\Server" instead of "Server". How do I fix this?