Teeny is a micro-route system that is really micro, supports PHP 5.3 to PHP 8, is extremely simple and ready to use.

For create your project use:
composer create-project inphinit/teeny <project name>
Replace <project name>
by your project name, for exemple, if want create your project with "blog" name (folder name), use:
composer create-project inphinit/teeny blog
Download without composer
If is not using composer
try direct download from https://github.com/inphinit/teeny/releases
Copy release or create project in Apache or Nginx folder and configure Vhost in Apache or execute direct from folder
For use with composer-auto configure index.php
like this:
<?php
require_once 'vendor/teeny.php';$app = new \Inphinit\Teeny;...return $app->exec();
For use without composer-autoload
<?php
require_once 'vendor/teeny.php';
require_once 'vendor/autoload.php';$app = new \Inphinit\Teeny;...return $app->exec();
Stand-alone server
For use without Apache or Nginx you can execute this command in folder:
php -S localhost:8080 index.php
Handling Http errors (like ErrorDocument)
For handling errors for not defined routes (404 Not Found) and when try access a route with invalid (not defined) method uses $app->handlerCodes(array $codes, mixed $callback)
, example (in routes.js), example:
$app->handlerCodes([ 403, 404, 405 ], function ($code) {
echo 'Custom page error ', $code;
});
Route patterns
You can create your own patterns to use with the routes in Teeny, but there are also ready-to-use patterns:
https://github.com/inphinit/teeny#types-of-params-named-in-routes
For use a pattern in routes, set like this:
$app->action('GET', '/user/<name:alnum>', function ($request, $response, $params) {
return "Hello {$params['name']}";
});$app->action('GET', '/api/<foobar:version>', function ($request, $response, $params) {
return "Version: {$params['foobar']}";
});$app->action('GET', '/product/<id:num>', function ($request, $response, $params) {
return "Product ID: {$params['id']}";
});...return $app->exec();