Вопрос

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 {}
?>
Это было полезно?

Решение

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").

Другие советы

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top