php[architect] logo

Want to check out an issue? Sign up to receive a special offer.

Fat-Free, a new PHP framework

Posted by on February 26, 2010

The newest player in the ever growing market of PHP frameworks is the PHP Fat-Free Framework (also called F3). The framework is a real lightweight; the basic functions are embedded in one file, one class, consuming only 39kb of disk space. This basic functionality includes a very simple to use Router, nifty template system and an easy-to-use SQL Handler. Everything you need to start creating a site. An important advantage of the framework is that the only requirement is PHP 5.3+. No PHP PECL modules, no PEAR libraries, no external classes nor third-party components. It’s all there, in one class.

Since this framework is quite new there are almost no tutorials available yet. Don’t let that scare you off, the documentation on the site is excellent. It’s on the same page as the one linked to above (if you don’t see it, scroll down). Contained within the download is also a handy quick reference card that lists all the functions. Also included in the download file is a file called F3ex.php which contains some extra’s like a CAPTCHA generator.

Using PHP 5.3 gives F3 the advantage of namespaces. As long as you put your functions in different files you can name the same since the framework wraps each file into their own namespace. Variables are also in these namespaces, so using the same variable name in different pieces of your code is possible without getting bugs you can’t figure out how to fix.

Taking the Fat-Free concept even further they provide an automatic way to compress Javascript/CSS with their F3ex.php expansion pack. Even the filesystem becomes lighter — F3 does not enforce a file structure unlike other frameworks do.

One thing is sure, this framework is anything but usual, yet it is very usable. I think we will see some great and smooth running, sites made with this framework in the future.

Marco is the keeper of keys and Chief Garbage Collector at Blue Parabola. He can be found on Twitter as @mtabini.
Tags: , , , ,

Responses and Pingbacks

There are some inaccuracies in this post.

1) F3 is not one single class (there are 3 classes defined in F3.php: F3, Runtime and XMLTree).

2) It does not use 5.3 namespaces.

Koen van Urk on
March 2nd, 2010 at 11:07 am


1) I’m sorry, I meant to say that you only had to use one class, which is the one you make all the calls to (F3::route, F3::run, etc.). Sorry for any confusion.

2) Within the documentation there is the line shown below. It got me tricked into actually believing it was PHP 5.3 namespaces, taking a closer look at the code shows I was indeed incorrect.

“Having different namespaces for each imported file gives application development teams a worry-free approach to coding. There is no way one programmer will clobber a variable or function with the same name defined by another. If you need to share function libraries with other members of your team, you can still use the PHP include or require command sets within each independent imported file.”

Thank you for your input Richard!

Been playing around with this framework, i think i like it. I like the fact that it doesnt force you to use its own directory structure like cakephp does. Very nice

Why is ‘enforcing file structure’ a bad thing ? Okay I’ll admit I like doing things ‘my way’ (or the highway) but working in teams it will work better if files are always in the same place.

Furthermore, it only runs on 5.3 and while it’s not really a problem for some, a lot of people use shared hosting and just cannot upgrade to a new version of PHP at will and in my opinion, it does not really need 5.3. Okay, it uses closures/ananymous functions, but those could be avoided (in my opinion : should be) and replaced by something that’s actually maintainable.

Fat-Free Framework 2.0 has just been released. It’s packed with new exciting features, outstanding documentation and improved overall performance. F3 still retains its lightweight footprint and remains true to its promise of being easy to use even for novices, yet stable and powerful enough to run high-traffic Web sites.

What are another PHP microframeworks similar to Fat-Free Framework?

Leave a comment

Use the form below to leave a comment: