linio / tortilla
A highly opinionated microframework built with speed and simplicity in mind.
Installs: 2 992
Dependents: 2
Suggesters: 0
Security: 0
Stars: 13
Watchers: 56
Forks: 0
Open Issues: 2
Requires
- php: >=8.1
- linio/common: ^4.1
- linio/microlog: ~1.0
- linio/util: ~4.0
- monolog/monolog: ^2.3
- nikic/fast-route: ~1.1
- pimple/pimple: ~3.0
- symfony/event-dispatcher: ~6.1.9
- symfony/http-foundation: ~6.1.9
- symfony/http-kernel: ~6.2.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpspec/prophecy: ^1.16
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-10-28 19:08:44 UTC
README
Linio Tortilla provides a very thin web abstraction layer built on top of FastRoute and Pimple. No frills, light and efficient. We believe that the web is just a delivery mechanism and no framework should dictate how you design the architecture of your applications.
And, just like a tasty super-thin tortilla, you can wrap it around anything you want.
Install
The recommended way to install Linio Tortilla is through composer.
{ "require": { "linio/tortilla": "~1.2" } }
If you need help preparing your tortilla, there are recipes available:
$ composer create-project linio/burrito-recipe full_app
$ composer create-project linio/tortilla-recipe basic_app
Tests
To run the test suite, you need install the dependencies via composer, then run PHPUnit.
$ composer install
$ phpunit
Goals
- Efficiency at all costs
- Reduce, as much as possible, the amount of moving parts under the hood
- Tackle complexity
Usage
Preparing your tortilla is quite simple. This is an example of a simple front-controller:
<?php require '../vendor/autoload.php'; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Linio\Tortilla\Application; $app = new Application(); $app->get('/hello/{name}', function (Request $request, $name) { return new Response('Hello ' . $name); }); $app->run();
You can also define controllers as services instead of closures. Since a Tortilla application is also a Pimple container:
<?php require '../vendor/autoload.php'; use Linio\Tortilla\Application; $app = new Application(); $app['default'] = function () { return new Acme\Controller\DefaultController(); }; $app->get('/hello/{name}', 'default:indexAction'); $app->run();
Defining actions
The Linio Tortilla dispatcher will always dispatch the HTTP request to your controller actions as the first argument. The method signature looks like this:
use Symfony\Component\HttpFoundation\Request; public function yourAction(Request $request, $arg1, $arg2, ...);
We do this to keep the dispatching procedure efficient. If we decided to use PHP's reflection mechanism to decide whether to inject the request object or not, we would lose precious milliseconds.