Fat-Free Framework
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):
- An autoloader (how could I ever code in PHP without an autoloader?! I knew they existed, but never tried them. Everything is so much easier now!)
- A markdown parser
- A nice little templating language (of course STE is still better :P)
- A database abstraction layer
- Bcrypt
- Caching
- Session management
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. ♥