So i'm making a wordpress website where I want to migrate my wordpress website to an online hosting platform. I did that with the all-in-one Wp Migration plugin, but i got a critical error message.
I fixed it and looked in the directadmin panel for apache errors. The problem is the custom theme I am making. I'm using an spl_autoload_register function from php and it gives the following error in directadmin:
Backend fatal error: PHP Fatal error: Uncaught Error: Class 'Website\Backend' not found in
The code i'm using for my autoload function is this:
File: functions.php
include __DIR__ . '/autoloader.php' ;
$backend = new Website\Backend();
File: autoloader.php
spl_autoload_register(function($className) {
$className = ltrim($className, '\\');
$className = str_replace(__NAMESPACE__, '', $className);
$path = __DIR__ . '/classes/' . str_replace('\\', '/', $className) . ".class.php";
if(file_exists($path)) {
include $path;
}
return;
});
file: backend.php
namespace Website;
class Backend
{
}
folderstructure:
- classes/
- website/
- backend.class.php
- website/
- functions.php
- index.php
Works on local server but not on hosting Anything doing wrong here?