Skip to content

andicooxy/leaf

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

246 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



Leaf PHP Framework





Latest Stable Version Total Downloads License

Leaf 2.1

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

Installation

It's recommended that you use Composer to install Leaf.

composer require leafs/leaf

This will install Leaf in your project directory.

If you don't want this method, you can simply clone this repo and run composer install to download any dependencies. You can then start your server and build your leaf app.

Basic Usage

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

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

// Instantiate Leaf
$app = new Leaf\App;

// In v2.0, the request and response objects are directly tied to the Leaf Object,
// so you don't have to instanciate them if you don't want to

// Example get route
$app->get('/', function () use($app) {
  // since the response object is directly tied to the leaf instance
  $app->response->renderMarkup('<h5>My first Leaf app</h5>');
});

$app->post('/users/add', function () use($app) {
  $name = $app->request->get('name');
  $app->response->respond(["message" => $name." has been added"]);
});

// Don't forget to call leaf run
$app->run();

You can view the full documentation here

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

php -S localhost:8000

Working With MVC

Although leaf on it's own isn't an MVC framework, it contains useful tools and packages which allow you to use Leaf as any other MVC framework.

If however, you want an already built MVC setup with scaffolding and a whole lot of other amazing features, you can try out Leaf API or Leaf MVC.

Leaf API

Leaf API is a lightweight PHP MVC framework for rapid API development. Leaf API serves as minimal MVC wrapper around Leaf PHP Framework which allows you to use Leaf in an MVC environment. It also comes along with a bunch of handy tools which can speed up your development by leagues🙂

Read the docs and Contribute on github.

About

Create clean, simple but powerful web apps and APIs quickly

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • PHP 97.9%
  • HTML 2.1%