문제

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