Skip to content

Latest commit

 

History

History
49 lines (39 loc) · 1.64 KB

README.md

File metadata and controls

49 lines (39 loc) · 1.64 KB

Teensy PHP

Teensy PHP is a micro web framework for rapidly creating REST APIs and hypermedia.

Project Status

Build codecov CodeFactor

Features

  • Lightweight Framework
  • Simple Router
  • PHP Templating Engine
  • Middleware Support
  • Easy to inject or replace functionality (its just some small functions)

Example

// index.php
<?php
require_once __DIR__ . '/vendor/autoload.php';

router(function() {
    // uncomment when using laravel valet/herd or when mod_rewrite is unavailable:
    // use_request_uri();
    //
    // healthcheck
    route(method(GET), url_path("/"), fn () => render(200, json_out(['status' => 'up'])));
    
    // Example url parameter
    route(method(GET), url_path_params("/hello/:name"), function () {
        render(200, html_out(template('src/templates/hello.php', ['name' => $_GET[':name']])));
    });
    
    // Example JSON body (echo server)
    route(method(POST), url_path("/echo"), function () {
        $body = json_in();
        render(201, json_out($body));
    });
});

Requirements

  • PHP 7.2+
  • Composer

Documentation

Please see the wiki for more information on how to rapidly create apps with teensyphp.