Leaf is a PHP micro framework that helps you create clean, simple but powerful web apps and APIs quickly.

v2.5.1 2021-05-30 13:34 UTC



Leaf PHP Framework

Leaf PHP

Latest Stable Version Total Downloads License

Leaf is a PHP framework that helps you create clean, simple but powerful web apps and APIs quickly and easily. Leaf introduces a cleaner and much simpler structure to the PHP language while maintaining it's flexibility. With a simple structure and a shallow learning curve, it's an excellent way to rapidly build powerful and high performant web apps and APIs.


You can easily install Leaf using Composer.

composer require leafs/leaf

This will install Leaf in your project directory.

Basic Usage

This is a simple demonstration of Leaf's simplicity. After installing Leaf, create an index.php file.

require __DIR__ . "vendor/autoload.php";

$app = new Leaf\App;
$auth = new Leaf\Auth;

$auth->connect("host", "user", "pass", "db name");

// Base example
$app->get("/", function() use($app) {
    "message" => "Welcome!"

// Full login example
$app->post("/auth/login", function() use($app, $auth) {
  $credentials = $app->request()->get(["username", "password"]);

  $user = $auth->login("users", $credentials, [
    "username" => ["username", "max:15"],
    "password" => ["text", "NoSpaces", "min:8"],

  if (!$user) {



You may quickly test this using the built-in PHP server:

php -S localhost:8000

You can view the full documentation here

Working With MVC

Leaf has recently added a new package to it's collection: LeafMVC. It's an MVC framework built with this package at it's core that let's you create clean, simple but powerful web applications and APIs quickly and easily.

Checkout LeafMVC here

Working with API

Leaf also added a simple framework constructed in an MVCish way, but without the View layer purposely for creating APIs and Libraries. Leaf terms this construct as MRRC(Model Request Response Controller😅😅😅). This let's you seperate API logic, data and "views"(request and response) just like how it's done in MVC.

Checkout the LeafAPI package here


Skeleton is the latest package included in the Leaf family. Skeleton is a customizable and simple to use boilerplate powered by Leaf. Skeleton gives you the power of other setups like Leaf MVC without the restrictions of those full blown frameworks. Use and contribute to Skeleton

Of course, with this core package, you can build your app in any way that you wish to as Leaf contains all the required functionality to do so

View Leaf's docs here

Built with ❤ by Mychi Darko