2017 © Pedro Peláez
 

library framework

Versatile PHP micro-framework for build APIs and websites quickly

image

luthier/framework

Versatile PHP micro-framework for build APIs and websites quickly

  • Saturday, July 21, 2018
  • by andersonsalas
  • Repository
  • 1 Watchers
  • 2 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

, (*1)

WARNING: Under development!, (*2)

Luthier Framework is a versatile PHP micro-framework for build APIs and small websites quickly. When we say "micro" we mean REALLY micro: in fact, only Composer and a single .php file is required to start., (*3)

Features

  • Based on the Symfony components
  • Easy to learn and extend
  • Powerful and flexible router with middleware support
  • CSRF protection
  • JSON and XML response helpers
  • Validator with translated error messages
  • Dependency Injection container
  • Command Line Interface command creation
  • Built-in plain PHP template engine with Twig and Blade integration

Requirements

  • PHP >= 7.1.8
  • Composer

Installation

Get Luthier Framework with composer:, (*4)

composer require luthier/framework 

Usage

Basic example:, (*5)

<?php 
# your_app/index.php 

require 'vendor/autoload.php'; 

$app = new Luthier\Framework(); 

$app->get('/', function(){ 
    $this->response->write("Hello world!"); 
}); 

$app->group('api', function(){ 

    $this->get('/', function(){ 
        json_response(['message' => 'Welcome to Luthier Framework!']); 
    }); 
    $this->get('about', function(){ 
        json_response(['version' => Luthier\Framework::VERSION]); 
    }); 

}); 

$app->run(); 

Defining routes:, (*6)

$app->get('foo/', function(){ 
    // Default template engine (will search for /foo.php file) 
    view('foo'); 
}); 

$app->post('bar/', function(){ 
    view('bar'); 
}); 

$app->match(['get','post'], 'baz/', function(){ 
    view('baz'); 
}); 

Router parameters:, (*7)

$app->get('hello/{name}', function($name){ 
    $this->response->write("Hello $name!"); 
}); 

// Optional parameters 

$app->get('about/{category?}', function($category = 'animals'){ 
    $this->response->write("Category: category"); 
}); 

// Regex parameters 

$app->get('website/{((en|es|fr)):lang}', function($lang){ 
    $this->response->write($lang); 
}); 

Route middleware:, (*8)

// Global middleware: 

$app->middleware(function($request, $response, $next){ 
    $response->write('Global <br>'); 
    $next($request, $response); 
}); 

// Global middleware (but not assigned to any route yet) 

$app->middleware('test', function($request, $response, $next){ 
    $response->write('Before route<br>'); 
    $next($request, $response); 
    $response->write('After route <br>'); 
}); 

$this->get('/', function(){ 
    $this->response->write('Route <br>') 
})->middleware('test'); // <- assign the 'test' middleware to this route 

Documentation

Coming soon!, (*9)

  • Luthier CI: Improved routing, middleware support, authentication tools and more for CodeIgniter 3 framework
  • SimpleDocs: Dynamic documentation library for PHP which uses Markdown files

If you love our work, consider support us on Patreon, (*10)

The Versions

21/07 2018

dev-master

9999999-dev https://luthier.ingenia.me/framework/en/

Versatile PHP micro-framework for build APIs and websites quickly

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware framework routing dependency-injection micro-framework luthier