Fat-Free Framework autoloader is very simple. He expects you to define one or more startup folders, each of which will map to the root namespace.
So, let's say you define $f3->set('AUTOLOAD','app/;inc/') , and your file structure is:
- app - inc - lib |- base.php - index.php
Then a class named MyClass belonging to the Foo\Bar namespace (full path: Foo\Bar\MyClass ) must be stored either in app/foo/bar/myclass.php or inc/foo/bar/myclass.php (remember : we specified two startup folders).
NB : do not forget to specify namespace Foo\Bar at the beginning of myclass.php (the autoloader will not do this for you).
-
So, to answer your specific problem, having the following file structure:
- lib |- base.php - src |- controllers |- index.php - index.php
Three configurations are possible:
Configuration 1
$f3->set('AUTOLOAD','src/controllers/')
Then all files under src/controllers/ will be automatically downloaded, but remember: src/controllers/ mapped to the root namespace , therefore, means that the Index class must belong to the root namespace (full path: \Index ).
Configuration 2
$f3->set('AUTOLOAD','src/')
Then all files under src/ will be automatically loaded, which means that the Index class must belong to the Controllers namespace (full path: \Controllers\Index ).
Configuration 3
$f3->set('AUTOLOAD','./')
Then all files under ./ will be automatically loaded, which means that the Index class must belong to the Src\Controllers namespace (full path: \Src\Controllers\Index ).