I have a REST api app using SLIM framework.
Below is my app dir structure
Below is structure in my controllers dir
Authcontroller.php is in Auth folder.
Below are namespaces given to ActionController and Authcontroller
Both controllers (Action and Auth) are defined in container as below in the mainapp
Above app is working fine on my localhost ,but when i upload same to my server, it get below error on above line 58
Please help me here , i am going mad,have changed around 3 hosting servers(SHARED-HOSTING),but still same error. PLEASE HELP!!
If your deployment server is Linux, mostly, because path is case-sensitive.
If your composer.json
contains section such as below
...
"autoload": {
"psr-4": {
"App\\": "app"
},
},
...
Composer PSR-4 autoloading expect to find class
\App\Controllers\Auth\AuthController
in file
app\Controllers\Auth\AuthController.php
but it can not find it because yours is
app\controllers\Auth\AuthController.php
Since your development machine seems to use Windows which by default is case-insensitive,
app\controllers\Auth\AuthController.php
equals to
app\Controllers\Auth\AuthController.php
Which is why it works on your development machine but not on deployment server.
So the solution is to rename any directory/files to match its case and also make sure that all files is copied to deployment server.
After you change directory/filename case, run
$ composer dump-autoload
So new autoload file is generated.