• Stars
    star
    1,015
  • Rank 43,723 (Top 0.9 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 4 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ The easiest way to create clean, simple but powerful web apps and APIs quickly




Leaf 3

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.

๐Ÿ—‚ Basic Usage

This is a "hello world" application created using Leaf. After installing Leaf, create an index.php file.

<?php

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

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

app()->run();

You may quickly test this using the Leaf CLI:

leaf serve

Or with the built-in PHP server:

php -S localhost:8000

๐Ÿ Why Leaf?

When it comes to building web applications, there are numerous tools and frameworks at your disposal. Nevertheless, we are convinced that Leaf is the optimal selection for developing powerful, web applications and APIs.

The problems

While PHP frameworks can make web development faster and more efficient, there are some potential challenges or drawbacks to using them, including:

  • Learning curve: Most PHP frameworks have a steep learning curve, especially for developers who are new to the language or the framework's conventions.
  • Performance overhead: Some PHP frameworks can add unnecessary performance overhead, due to the additional abstraction layers and features they provide.
  • Code maintenance: Most frameworks require adhering to specific coding standards and conventions, which can make maintenance and updates more challenging if you are not already familiar with those standards.
  • Limited flexibility: PHP frameworks can be more rigid than writing code from scratch, as they may require you to adhere to specific coding standards and conventions. This can limit your flexibility in terms of how you structure your code and handle specific use cases.
  • Compatibility with other systems: Most PHP frameworks are bound to a particular ecosystem and make it difficult to randomly pick and use packages which don't have support for the framework you are using.
  • Packing a ton of unused code/packages: Just about every PHP framework out there adds a ton of complexity to your applications in the form of unused code, classes and packages. This in turn leads to bloat and ultimately a drop in performance

How Leaf tackles these

Leaf 3 provides a bunch of features that aim to tackle these common problems found in just about every PHP framework out there.

  • Low barrier to entry

    Leaf is the easiest framework to learn with PHP newbies building powerful leaf apps in a few minutes of reading the docs/watching out tutorial videos. All you truly need to get started with Leaf is basic PHP knowledge and optional but recommended knowledge on some backend concepts like JWT auth and more.

  • Lightweight

    Leaf 2 was lightweight and fast enough to be considered one of the most lightweight but powerful frameworks around, and Leaf 3 makes leaf 2 look like a joke. Leaf 3 can now be considered the most lightweight PHP framework with a source of about 30kb and allows you to build full apps and APIs which end up less than 20mb including user dependencies (leaf api). This is a big haul compared to other frameworks that require dependencies and tons of files which end up more than 200mb.

    image

    a comparison with slim - slim (left) - leaf (right)

  • Enables high developer productivity

    A whole lot of research and testing has been done to build amazing features which allow developers to focus on only what they need: their apps. Leaf 3 has put tons of strategies together to create the best developer experience known to PHP. From things like removing class initializers and creating global functions which allow you call classes from anywhere in your application, modules and other amazing leaf features.

  • Powered by modules

    Leaf 3 and its ecosystem are heavily powered by modules, which are simply pieces of leaf's functionality shipped into independently installable libraries. Modules help make leaf even more lightweight and help developers only deal with features which they need in their applications. This means that you only install what you need.

  • Easy to use features

    As mentioned above, a lot of research has gone into the developer experience for leaf 3 and one aspect was to make our existing features more performant and easier to use. We employed various strategies like modeling some features after popular libraries in other languages and frameworks. For instance, the API for leaf cors is almost an exact replica of the expressjs cors middleware.

  • Library/Framework compatibility

    Since the beginning of Leaf, we've set out to create code which could easily be integrated with other libraries and frameworks. No matter how powerful leaf is, we try to base of everything we do on simple concepts as opposed to other frameworks which need things like providers in order to access framework features in libraries.

  • Scalability

    One of the most beautiful things about leaf is that, no matter what package you're using with leaf, if it works in development, it will definitely work in production with near zero config, unless you want some special features. Leaf provides a core and other frameworks/libraries that build around leaf. This makes leaf appropriate for almost any project no matter it's size.

๐Ÿ“ฆ Installation

You can create a Leaf 3 app with the Leaf CLI

leaf create <project-name> --v3 --basic

<project-name> is the name of your project

You can also use Composer to install Leaf 3 in your project quickly.

composer require leafs/leaf

โœˆ๏ธ The Leaf Ecosystem (Libs & Frameworks)

Project Status Description
leaf Latest Stable Version Total Downloads Create websites and APIs quickly
leafmvc Latest Stable Version Total Downloads An MVC wrapper for leaf (for general development)
leafapi Latest Stable Version Total Downloads An MVC wrapper for leaf geared towards API development
skeleton Latest Stable Version Total Downloads Leaf boilerplate for rapid development
leaf-ui Latest Stable Version Total Downloads A PHP library for building user interfaces
cli Latest Stable Version Total Downloads CLI for creating & interacting with your leaf apps

๐Ÿงฉ The Leaf Ecosystem (Modules)

Project Status Description
alchemy Latest Stable Version Total Downloads A test runner for your Leaf apps
aloe Latest Stable Version Total Downloads Smart console helper for leaf mvc, leaf api and skeleton
anchor Latest Stable Version Total Downloads Basic security tools
auth Latest Stable Version Total Downloads Simple but powerful authentication system for your apps
bareui Latest Stable Version Total Downloads Dead simple templating engine with no compilation (blazing speed)
blade Latest Stable Version Total Downloads Laravel blade templating port for leaf
cookie Latest Stable Version Total Downloads Cookie management without the tears
cors Latest Stable Version Total Downloads CORS operations made simple
csrf Latest Stable Version Total Downloads Basic CSRF protection
date Latest Stable Version Total Downloads PHP dates for humans
date Latest Stable Version Total Downloads Devtools for your Leaf app
db Latest Stable Version Total Downloads Leaf Db from v2 (actively maintained)
db-old Latest Stable Version Total Downloads Leaf Db from v1 (still maintained)
exception Latest Stable Version Total Downloads Leaf's exception wrapper (fork of whoops)
experiments Latest Stable Version Total Downloads collection of experimental modules
fetch Latest Stable Version Total Downloads HTTP requests made simple
form Latest Stable Version Total Downloads Form processes and validation
fs Latest Stable Version Total Downloads Awesome filesystem operations + file uploads
http Latest Stable Version Total Downloads Http operations made simple (request, response, ...)
logger Latest Stable Version Total Downloads leaf logger module
mail Latest Stable Version Total Downloads Mailing made easy with leaf
mvc-core Latest Stable Version Total Downloads Core MVC tools powering our MVC wrappers
password Latest Stable Version Total Downloads Password encryption/validation/hashing in one box
redis Latest Stable Version Total Downloads Redis module
router Latest Stable Version Total Downloads Default router for leaf php
session Latest Stable Version Total Downloads PHP sessions made simple
tilly Latest Stable Version Total Downloads Simple utility 'toolkit' for PHP applications
veins Latest Stable Version Total Downloads Leaf veins templating engine
viewi Latest Stable Version Total Downloads Leaf integration with Viewi PHP

๐Ÿ’ฌ Stay In Touch

๐Ÿ““ Learning Leaf 3

  • Leaf has a very easy to understand documentation which contains information on all operations in Leaf.
  • You can also check out our youtube channel which has video tutorials on different topics
  • You can also learn from codelabs and contribute as well.

๐Ÿ˜‡ Contributing

We are glad to have you. All contributions are welcome! To get started, familiarize yourself with our contribution guide and you'll be ready to make your first pull request ๐Ÿš€.

To report a security vulnerability, you can reach out to @mychidarko or @leafphp on twitter. We will coordinate the fix and eventually commit the solution in this project.

๐Ÿคฉ Sponsoring Leaf

Your cash contributions go a long way to help us make Leaf even better for you. You can sponsor Leaf and any of our packages on open collective or check the contribution page for a list of ways to contribute.

And to all our existing cash/code contributors, we love you all โค๏ธ

๐Ÿคฏ Links/Projects

More Repositories

1

leafMVC

MVC "Framework" created from Leaf PHP Framework
PHP
44
star
2

leafAPI

Leaf API is a lightweight PHP MVC framework for rapid API development.
PHP
36
star
3

ui

Leaf UI is a PHP library for building user interfaces.
PHP
33
star
4

skeleton

A boiler-plate application for rapid development.
PHP
15
star
5

cli

๐ŸŽฎ A simple command line tool for installing and interacting with your leaf apps
TypeScript
10
star
6

hana

โš›๏ธ Simple, lightweight React framework for humans
TypeScript
8
star
7

docs

๐Ÿคซ New documentation for leaf and components
JavaScript
8
star
8

eien

Leaf's very own high-speed, high-performance server
PHP
8
star
9

http

๐Ÿ“ก Leaf Http module
PHP
7
star
10

viewi

๐Ÿšฆ Viewi PHP integration for your Leaf apps
PHP
6
star
11

fetch

Fun, super simple and easy to use http client
PHP
6
star
12

db

๐Ÿ—„ Leaf PHP db module
PHP
6
star
13

aloe

Stupidly smart and simple console for your Leaf apps
PHP
5
star
14

router

๐Ÿš router module for leaf PHP
PHP
5
star
15

mail

๐Ÿ“ฉ Leaf PHP mailer module
PHP
5
star
16

auth

๐Ÿ” Leaf PHP auth module
PHP
4
star
17

bareui

๐ŸŽจ Leaf PHP BareUI module
PHP
4
star
18

devtools

๐Ÿง‘๐Ÿพโ€๐Ÿ’ป Browser DevTools for your Leaf app
TypeScript
4
star
19

mvc-core

Core functions and configurations for Leaf MVC, Leaf API and Skeleton
PHP
3
star
20

queue

๐Ÿ› ๏ธ [WIP] Queue/Worker implementation for Leaf
PHP
3
star
21

form

๐Ÿ“ Leaf form module
PHP
3
star
22

date

๐Ÿ“… Leaf PHP date/time module
PHP
3
star
23

new-docs

New documentation for Leaf PHP Framework
CSS
2
star
24

fs

๐Ÿ—‚ Leaf FileSystem module
PHP
2
star
25

cli-docs

๐ŸŽฎ Docs for leaf CLI
HTML
2
star
26

demos

๐Ÿคก Demo Apps built with leaf (WIP)
PHP
2
star
27

session

๐Ÿ’ฝ Leaf session module
PHP
2
star
28

anchor

๐Ÿ” Leaf PHP security module
PHP
2
star
29

cookie

๐Ÿช Leaf PHP cookie module
PHP
2
star
30

cors

๐Ÿ”– CORS module for leaf + PHP
PHP
2
star
31

logger

๐Ÿ“‚ Logging for leaf php
PHP
2
star
32

experimental-modules

๐Ÿ”ฌA collection of experimental modules
PHP
2
star
33

password

๐Ÿ”‘ Leaf PHP password helper module
PHP
2
star
34

csrf

๐Ÿ” CSRF module for leaf anchor
PHP
2
star
35

veins

Templating engine for Leaf PHP framework
PHP
2
star
36

leafMVC-docs-old

Docs for LeafMVC
JavaScript
1
star
37

blog

๐Ÿ“š Official blog for leaf php
Vue
1
star
38

alchemy

โš—๏ธ Modern and Delightful PHP testing library focused on simplicity
PHP
1
star
39

tilly

Utility Functions? Helpers? Whatever
PHP
1
star
40

leaf-vein-support

VScode syntax support for Leaf Veins (Leaf templating engine)
1
star
41

codelabs

โšก๏ธ The interactive Leaf/PHP Guide
Vue
1
star
42

mvc-docs

โšก๏ธ Documentation for leaf mvc
Vue
1
star
43

Shu

Shลซ is an event-driven state library (aka state machine) for your PHP apps
PHP
1
star
44

skeleton-docs

๐Ÿฆด Documentation for skeleton
Vue
1
star
45

api-docs

๐Ÿ“š Documentation for leaf API
Vue
1
star
46

feature-requests

๐Ÿ“ช A space to organize all Leaf feature requests from the community
1
star