Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Using namespaces in PHP :: Fatal Error Core\App not found

Discussion in 'General Discussion' started by Ivo Danic, May 22, 2016.

  1. Ivo Danic

    Ivo Danic Active Member

    Joined:
    Dec 1, 2015
    Messages:
    29
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    México
    cPanel Access Level:
    Root Administrator
    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:

    • 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:

    • 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?
     
    #1 Ivo Danic, May 22, 2016
    Last edited by a moderator: May 22, 2016
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,400
    Likes Received:
    1,952
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice