Search code examples
phpfat-free-framework

Autoloading not working


I'm just trying out Fat-Free Framework and I come to some trouble.
I try to use the autoloading to load one of my routes, like this :

<?php
$f3 = require 'vendor/bcosca/fatfree-core/base.php';

$f3->set('DEBUG', 3);

$f3->set('AUTOLOAD', 'app/');

$f3->config('app/routes.ini');

$f3->run();

I have a app/ dir, and a routes.ini file in it, like this :

[routes]
GET / = Test->show

Then, I have a Test.php file in app/, with this in it :

<?php
class Test {

    function show($f3) {
        echo 'ok !';
    }

}

After running this I get a big fancy error saying the following :

Method Not Allowed

HTTP 405 (GET /)

Any ideas ? (It isn't my PHP Version, if you'd ask yourself)


Solution

  • Your initial code is fine. It's just that your Test class conflicts with the framework's own Test class.

    Rename it to anything else and it should work.