Skip to content

Meet Leaf PHP

Leaf is PHP made simple—elegant, intuitive, and easy to pick up, with lightweight tools that help makers build, ship, and scale effortlessly.

php
<?php

require __DIR__ . '/vendor/autoload.php';

app()->get('/', function () {
  response()->json(['message' => 'Hello World!']);
});

app()->run();

Leaf handles the heavy lifting so you can focus on building. It provides a simple routing system, powerful middleware support, seamless database integration, and a whole lot more.

As we love to say, "Writing code should be simple and fun, and that's what Leaf is all about."

Why Leaf?

Most PHP frameworks are complex, slow, and opinionated. Leaf is different—it's built for makers.

  • 🚀 Beginner-friendly – Get started in minutes with just basic PHP knowledge.
  • ⚡ Lightweight & fast – A minimal core with high performance and low memory usage.
  • 🛠️ Built for makers – Simple APIs, class-free initializers, and global functions that let you focus on shipping.
  • 🔗 Seamless integration – Works effortlessly with any library or framework—no complex setups required.
  • 📈 Scales with you – Everything you need—routing, database tools, authentication, and more—but stays unopinionated, letting you pick and choose what fits your project.

Creating a new app

Leaf is built to be incrementally adoptable: use it as a lightweight core for small to medium apps, or scale up with Leaf MVC for more structure in complex applications. No matter your stack, Leaf stays simple, fast, and developer-friendly—so you can build and ship with ease.

Technical Requirements

Before you start with Leaf, verify that your system has the following installed:

  • PHP v7.4 or higher
  • Composer (for package management)
  • Leaf CLI (optional but recommended for easier app management)
Don't have PHP & Composer installed?
  • Beyond Code released an amazing tool called Laravel Herd that provides a quick and easy way to set up a local PHP development environment for Mac and Windows. It's a great way to get started with PHP if you don't have it installed yet.

  • Another way to install PHP and Composer without any hassle is to use php.new which was created by Beyond Code. It's a quick way to get started on Windows, Linux and Mac with just one command.

  • A more traditional way on Windows, Linux and Mac, you can use Xampp, which is a free and open-source cross-platform web server solution stack package developed by Apache Friends, consisting mainly of the Apache HTTP Server, MariaDB database, and interpreters for scripts written in the PHP and Perl programming languages.

Once you install PHP and Composer, you can proceed with the installation of Leaf CLI:

bash
composer global require leafs/cli -W

Building your first app

After setting up Leaf CLI, you can create a new Leaf app using the create command:

bash
leaf create <project-name>

This will walk you through a quick setup process where you can select the kind of application you want to build. You can find more options in the CLI documentation.

Once your project is generated, you can run it using the serve command:

bash
leaf serve

That's it! You're now ready to start building with Leaf. 🍃

Building with Leaf

No project is the same, why should your tools be? Leaf is designed to be flexible and adaptable, so you can build your way. Choose your path and start building with Leaf:

Basic Leaf App

Use Leaf as a micro-framework to build simple apps and APIs.

Start building

Leaf MVC App

Add an MVC structure on top of Leaf for more complex apps.

Start building

MVC for APIs

Build APIs with a structured approach for better organization.

Start building

Released under the MIT License.