Hardware, programming and astronomy tutorials and reviews.

MVC in punFramework

How to use punFramework?

punFramework is a very simple MVC (Model-View-Controller) framework incorporated in fluxBB forum. It is designed as a tool allowing to add additional components to the forum like news, articles or other php script. punFramework can't modify punBB itself, it add extra pages with your code. The MVC design pattern allows you to create modules in a clean, unified and easy way.

All your code (modules) is accessed using mvc.php. You can rename the file to any name you want.


URL Router

punFramework uses simple url router:
mvc.php?c=CONTROLLER_NAME mvc.php?c=CONTROLLER_NAME&m=METHOD_NAME mvc.php?c=CONTROLLER_NAME&m=METHOD_NAME&var1=foo1&va2=foo2

Available punBB variables

The controllers have access to:
In fluxBB there isn't no $pun_user, however punFramework 07.2008 Beta still renames $forum_*internaly to old punBB variable naming.


Views should contain all the look and feel of your modules - they are templates. Each view must be saved as a NAME.php file, and it can contain PHP code.


Models are classes similar to Controllers (inherit punRoot) but they should contain only methods that use the database (like add, edit, delete entries). Use of models (or views) is optional but in the end will make your modules easy to modify and to extend.

Other Helpers

Error handling

When a framework encounters an error it will raise an Exception - a nice error handling "thing" which will be caught by the framework

PHP Tutorials and Scripts, 22 July 2008,

Comment article