Domanda

I am learning the fat free framework, but I've ran into a problem.

I tried out the F3 Autoloader and got this :

Internal Server Error
Fatal error: Class 'Gadgets\iPad' not found

In index.php I have written :

$f3->set('AUTOLOAD','autoload/');
$obj=new Gadgets\iPad;

and made a folder named Gadgets with a file in it, named ipad.php

In the file I put a class

<?php
    namespace Gadgets;
    class iPad {}
?>
È stato utile?

Soluzione

F3 checks the class name as normal and then again lower case, for each path in AUTOLOAD. The behaviour was tweaked in 3.1.2 so if you're using 3.1.1 you may have issues. Code snippet below from base.php:

is_file($file=$auto.$class.'.php') ||
is_file($file=$auto.strtolower($class).'.php') ||
is_file($file=strtolower($auto.$class).'.php'))

Your example won't work as it's neither correct case ("Gadgets/iPad.php") nor all lower case ("gadgets/ipad.php").

Altri suggerimenti

It depends on your OS, but you have to take care of uppercase and lowercase. It should work if you rename the ipad.php to iPad.php.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top