Search code examples
phpmodel-view-controllerframeworksaclfat-free-framework

F3 (Fat-Free PHP framework) and adding MVC / OOP structure to it


This question is in regard to F3 (Php Fat Free framework) onto which I have stumbled looking for a simple, fast and secure framework suitable for small websites and/or blogs. What was important to me was that the framework have some sort of ACL, and simplicity. If you know of any good alternatives, I'm all ears. In the meantime, a question about F3 for those who have had experience with it:

Is it possible to have a decent OOP MVC structure with F3? Since routes like F3::route('GET /',':indexController|home'); do not work, how would one implement a proper MVC structure? I know I can set the home method to static and then do F3::route('GET /','indexController::home');, but this seems like unnecessary complication and overkill, and ignores the construct method, which I need to set layout for each controller separately. What I would like to have in my index.php file are only the routes to the various controllers and actions, the rest of the logic will be handled in these controllers. What is the best way to approach this?

Many thanks

Edit: I would also like to hear some opinion on Yii, I see it ranked quite highly on PHPFrameworks.com


Solution

  • try f3::route('GET /',array(new IndexController,'home'));

    that's going to call your constructor and execute the home() method as well. f3 does not promote any "proper" MVC approach. instead, you have a "freehand" MVC approach.