Created an OOP-MVC-PDO-based CRUD operation. It will be appreciated if someone suggest some code improvement or let me know what I have done wrong or which way needs to be done. Thank you
First off your controllers folder is lowercase while the namespace is Controllers. Rename the folder to have uppercase C as well if you want to follow psr 4 autoload principles (same goes for other folders)
I'm curious as to why the vendor folder has been put on github? Normally the user would just run composer install or composer dump-autoload
And I would personally move index.php into the public directory. I get that it's easier with it in the base folder, but it allows anyone to access any file in all folders
@feralam That’s because the class App\Database\Connection isn’t located where Composer is expecting it.
Note that in PSR-4, you tell it where to look for classes based on their top-level namespace. When you do "Database\\": "database/", you’re saying that the class Database\Connection should be at /database/Connection.php – but in the actual class itself, you use the namespace App\Database, which falls under App, so Composer expects that class to be located at /app/Database/Connection.php.
If you fix the namespace in the Connection class, it should work.
@feralam You can use the “Set Best Answer” option on the answer that best answered the question to mark the problem as solved and get it off the unsolved list.