kilbiller / micro
A micro http framework for PHP inspired by zeit/micro
v0.0.2
2019-05-31 17:37 UTC
Requires
- php: >=7.3
- nyholm/psr7: ^1.1
- nyholm/psr7-server: ^0.3.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
- zendframework/zend-httphandlerrunner: ^1.1
This package is auto-updated.
Last update: 2024-10-29 05:34:39 UTC
README
Micro is a PHP micro-framework primarly designed to work with microservices. It is heavily inspired by zeit/micro (basically a port).
Highlights
- < 100 lines of code
- Uses psr7 http request/response so no need to learn anything new
- Modern (Fully typed, Requires PHP >= 7.3)
Installation
composer require kilbiller/micro
Usage
<?php declare(strict_types = 1); use \Psr\Http\Message\ServerRequestInterface as Request; use \Psr\Http\Message\ResponseInterface as Response; require 'vendor/autoload.php'; use function \micro\{createServer, micro}; createServer(micro(function (Request $req, Response $res) { $res->getBody()->write("Hello World."); return $res; }));
Advanced
It's possible to use a custom psr7 implementation by implementing your own createServer.
$fn => $fn($req, $res)
Thanks
Thanks to zeit for making micro.