I'm quite new to autoloading and namespaces, and attempting to add namespaces to my MVC project.
So In my composer I added:
"autoload": {
"psr-0": {
"prj\\app\\": "app/",
"prj\\app\\controller\\": "app/controller/",
"prj\\app\\classes\\": "app/classes/"
}
}
And then updated composer and ran the autodump command.
I then went back to my app to try use one of these namespaces however I just get the following back:
use \app\classes\engine; // use statement I tried
Fatal error: Uncaught Error: Class 'app\classes\engine' not found in C:\inetpub\wwwroot\web\index.php:87 Stack trace: #0 {main} thrown in C:\inetpub\wwwroot\web\index.php on line 87
I'm not sure why it is unable to find the class using the namespace, here's my entire folder structure if it may be of any use:
PRJ
├───app
│ ├───classes
│ └───controller
├───web
│ └───index.php
├───vendor
│ ├───bin
│ ├───composer
│ ├───...
└───view
├───bootstrap
└───default
/app stores the logic such as controllers and classes.
/web is the web root - the index.php is the page which visitors see and also everything is handled through here.
/vendor is the composer directory where my dependencies are stored.