Hi, im Laria

This website is no longer maintained. You can visit my new website laria.me instead!

Fat-Free Framework

( Posted: 2014-02-22 14:17:16 Tags: , , , )

I discovered the Fat-Free-Framework last week and fell in love with it. I am usually not a big fan of frameworks, since most of them enforce too many restrictions, but this one is really nice.

The only thing you really need to use is the really nice URL-Router. The rest is completely optional.

It includes (incomplete list):

The database abstraction layer is pretty neat. Let's say, you have this SQL Table modelling a user:

CREATE TABLE `users` (
    `id` int NOT NULL AUTO_INCREMENT,
    `name` text NOT NULL,
    `pwhash` text NOT NULL,
    `active` bool NOT NULL,
    PRIMARY KEY(`id`)
);

And now you want to activate the user named Foobar. You can do this like this:

$u = new \DB\SQL\Mapper($f3->get('DB'), 'users'); // Create mapper object for table 'users'.
$u->load(array('name=?', 'Foobar'));              // Get user with name 'Foobar'
$u->active = true;                                // Set attribute active to true.
$u->save();                                       // Save object to database

That was simple!

And I love how the Tutorial starts with this quote from Antoine de Saint-Exupéry:

A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away.

A framework dedicated to minimalism. ♥