Reputation: 45
Hello,
I moved my files from my local pc, running WAMP to my webserver, which is a Linux machine.
I work with composer to use its autoload functionality to load my MVC structure, more about that later.
The error that I receive on my webpage is the following:
Fatal error: Uncaught Error: Class 'App\Model\DB' not found in <folder_structure>/config/_boot.php:15
I do not have this error on my Windows machine, the code works perfectly there.
I use the same folder structure, which is (simplified) as following:
- config
-- _boot.php
- dist
-- index.php
-- includes
--- header.php
- src
-- app
--- Models
---- db.php
- composer.json
My config/_boot.php
file looks like this:
use App\Model\DB;
...
$db = new DB($database['host'], $database['dbname'], $database['user'], $database['password']);
My src/app/Model/db.php
file looks like this:
namespace App\Model;
class DB
{
}
My composer.json
contains this:
"autoload": {
"psr-4": {
"App\\": "src/app/"
},
"files": [
"src/app/functions.inc.php",
"config/_boot.php",
"src/app/Routing.php"
]
}
autoload_psr4.php
return array(
...
'App\\' => array($baseDir . '/src/app'),
...
);
Is there anyone who has an idea of what I am doing wrong?
"App\\Model\\": "src/app/Model/"
to my composer.json
as wellPS: This is my first question on Stackoverflow, tips on improving the layout are welcome...
Upvotes: 3
Views: 1288
Reputation: 3802
PSR-4 states:
The terminating class name corresponds to a file name ending in .php. The file name MUST match the case of the terminating class name.
You have broken this rule by placing DB
class into db.php
file. The reason it works on Windows and not on Linux is that the later is case-sensitive regarding file and folder names.
So the fix is to rename db.php
into DB.php
.
Upvotes: 4