Question

I have index.php where i keep my __autoload() function that loads classes from a lib folder.

 function __autoload($class) {
      if(file_exists(LIBS . $class .".php")){
           require LIBS . $class .".php";
      }
 }

I have a Dashboard class

 class Dashboard extends Controller {
      public function __construct(){
           Auth::handleLogin();
      }
 }

Using sudo apt-get install php5 and apache2 on Ubuntu 12.04 i am not able to autoload that Auth, what could possibly go wrong? It works on my other computer which uses a Bitnami XAMPP server.

This is the error i get:

 Fatal error: Class 'Auth' not found in /var/www/app/controllers/dashboard.php on line 6

Where the Auth::handleLogin(); is being called.

Was it helpful?

Solution

You're experiencing that because in linux the filesystem paths are case sensitive.

OTHER TIPS

i have linux mint 16 and i use this with namespaces when i do object declaration and it is work perfect

spl_autoload_register(function ($class) {

    $class = str_replace("\\", "/", $class);

    include $class . '.php';

});

in index file

require_once 'autoload.php';

$db = new DBWork\DBWork('localhost', 'northwind', 'root', '123');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top