model classes not found in subdirectories

60 views
Skip to first unread message

v.

unread,
Jul 15, 2019, 4:21:13 AM7/15/19
to Fat-Free Framework
I am trying to get some more structure in my app by moving some models in subdirectories.
Currently my app structure is
- app/controllers
- app/models
- app/views
I have done so for my controllers already without any issue.
When (in a controller) I try to call a model in a subdirectory (eg.: $model = new \Directory\ModelName() ) f3 throws a class not found error. (If I put ModelName.php directly in the root of the model directory it works fine using $model = new ModelName() ).

My config.ini file shows
AUTOLOAD=app/controllers/|app/models/

Shouldn't this just work out of the box?
What could be wrong?

ikkez

unread,
Jul 15, 2019, 4:32:43 AM7/15/19
to Fat-Free Framework
AUTOLOAD = app/

And in file app/models/modelA.php you need to have defined the namespace „Models“.
Then it’s just new \Models\ModelA() and it should work. Just the same for controller etc.

v.

unread,
Jul 15, 2019, 5:07:01 AM7/15/19
to Fat-Free Framework
Please forgive my Monday morning brain.
I forgot to include the namespace....
Reply all
Reply to author
Forward
0 new messages