Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
A single-file PHP micro-framework for building dynamic web applications with routing, templating, and SQL/NoSQL database support.
Fat-Free Framework (F3) is an open-source PHP micro-framework designed to build dynamic web applications using a single-file core, a high-performance URL routing engine, and a lightweight template system.
Fat-Free Framework (F3) is a PHP micro-framework authored by bcosca, distributed as a single base.php file (with optional plug-ins in lib/). It takes PHP route definitions and callback functions as input and produces rendered HTML, JSON, XML, or plain-text responses. The framework runs on any PHP 7.2+ server, including Apache, Nginx, Lighttpd, IIS, and PHP's built-in web server. F3 emphasizes minimalism: no required installation procedure, no complex configuration, and no fixed directory structure.
GET /brew/@count), named routes (GET @beer_list: /beer), ReSTful mapping via $f3->map(), AJAX/sync route modifiers, and beforeRoute/afterRoute event handlers.<include>), conditionals (<check>), repetition (<repeat>), and exclusion (<exclude>); it also works alongside Twig, Smarty, or plain PHP templates.'admin/autoload/; user/autoload/') and maps class names to directory nesting.$f3->set('hello.world', ...)) and automatic session management via the SESSION variable.Fat-Free suits PHP developers who want a micro-framework with no learning curve and no opinionated directory structure. Novice programmers can follow the "Hello World" example and be up and running in minutes, while expert developers can use advanced features like dynamic route handlers (@controller->@action) and ReST interfaces. It is also a good fit for teams building small-to-medium web applications, APIs, and prototypes that need fast iteration without the overhead of a full-stack framework.
$f3->map('cart/@item', 'Item') to create a ReSTful interface that handles GET, POST, PUT, and DELETE requests.<repeat> directive to loop over array data.LOCALES variable and dictionary files to serve localized content, supported by the framework's built-in multilingual features.$f3->reroute() to redirect users to a "site offline" page, or trigger $f3->error(404) when dynamic route parameters don't match database records.Fat-Free works by front-controller routing: after including base.php (or vendor/autoload.php via Composer), you register one or more routes with $f3->route(), optionally set framework variables with $f3->set(), and then call $f3->run() to start listening for requests. When a request matches a route pattern, F3 executes the associated callback or class method, populates the PARAMS array with URL tokens, and allows the handler to echo output or render a template.
base.php. No configuration is required for basic use. It supports six SQL/NoSQL databases out of the box and includes many optional plug-ins without bloating the core.PUT and DELETE methods are not implemented by regular HTML forms, so they must be called via AJAX.Fat-Free Framework (F3) is a PHP micro-framework that provides URL routing, a template engine, database mappers, and optional plug-ins, all condensed into a single-file core. It is designed to help developers build dynamic web applications quickly without complex configuration or rigid directory structures.
You can start a new project with composer create-project bcosca/fatfree or add it to an existing project with composer require bcosca/fatfree-core. Alternatively, download the distribution package and include lib/base.php directly in your application.
Yes, Fat-Free supports MySQL, SQLite, MSSQL/Sybase, PostgreSQL, DB2, and MongoDB off-the-shelf. It includes lightweight object-relational mappers (ORMs) for data abstraction and modeling, and no configuration is required to use them.
Fat-Free requires PHP 7.2 or later. Running it on an older PHP version will cause syntax errors because the framework uses modern language constructs such as closures and anonymous functions.
Yes, F3 includes a compiled template engine that parses directives like <include>, <check>, and <repeat>, and it also supports plain PHP templates. You can additionally use third-party template engines like Twig or Smarty with F3.