Using namespaces in PHP :: Fatal Error Core\App not found
stackoverflow.com/questions/37354112/using-namespaces-in-php-fatal-error-core-app-not-found
I made an MVC project in local (WAMP) and it runs perfectly. But when i deploy it in a web server apears this error:
Fatal error:Class'Core\App'not found in home/dmlink/public_html/public/index.php on line 14
This is the code of the line 14:
13: spl_autoload_register('autoload_classes');
14: $app =new \Core\App;
15: $app->render();
The structure of the project:
[LIST]
app : Here are the controllers, models, and views.
core: Here are the core files.
public: Since this directory runs the app.
I got the same version in the web server like in localhost:
[LIST]
php 5.5
apache 2.4
This is the complete code of index:
define('PROJECT_PATH', dirname(__DIR__));
define('APP_PATH', PROJECT_PATH .'/app');
function autoload_classes($class_name){
$file = PROJECT_PATH .'/'. str_replace('\\','/', $class_name).'.php';
if(is_file($file)){
include_once $file;
}
}
spl_autoload_register('autoload_classes');
$app =new \Core\App;
$app->render();
People told me that i need add the path to the core files, but where and how?
-
Hello, You may find the following third-party URL helpful: codeigniter MY_Controller not found Thank you. 0
Please sign in to leave a comment.
Comments
1 comment