https://github.com/ingeniasoftware/luthier-framework
Versatile PHP micro-framework for build APIs and websites quickly
https://github.com/ingeniasoftware/luthier-framework
framework micro-framework middleware php php-framework php7 psr7 router
Last synced: 10 months ago
JSON representation
Versatile PHP micro-framework for build APIs and websites quickly
- Host: GitHub
- URL: https://github.com/ingeniasoftware/luthier-framework
- Owner: ingeniasoftware
- License: mit
- Created: 2017-07-02T04:44:51.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-02-14T17:35:33.000Z (almost 7 years ago)
- Last Synced: 2025-03-24T09:11:33.402Z (11 months ago)
- Topics: framework, micro-framework, middleware, php, php-framework, php7, psr7, router
- Language: PHP
- Homepage: https://luthier.ingenia.me/framework/en/
- Size: 204 KB
- Stars: 15
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
WARNING: Under development!
**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.
### 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:
```
composer require luthier/framework
```
### Usage
Basic example:
```php
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:
```php
$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:
```php
$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:
```php
// Global middleware:
$app->middleware(function($request, $response, $next){
$response->write('Global
');
$next($request, $response);
});
// Global middleware (but not assigned to any route yet)
$app->middleware('test', function($request, $response, $next){
$response->write('Before route
');
$next($request, $response);
$response->write('After route
');
});
$this->get('/', function(){
$this->response->write('Route
')
})->middleware('test'); // <- assign the 'test' middleware to this route
```
### Documentation
Coming soon!
### Related projects
* [Luthier CI](https://github.com/ingeniasoftware/luthier-ci): Improved routing, middleware support, authentication tools and more for CodeIgniter 3 framework
* [SimpleDocs](https://github.com/ingeniasoftware/simpledocs): Dynamic documentation library for PHP which uses Markdown files
### Donate
If you love our work, consider support us on [Patreon](https://patreon.com/ingenia)