phpbg / mini-httpd
This is a small http server framework built on top of react http. It allows to quickly build simple applications
Installs: 73
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 1
Open Issues: 0
Language:JavaScript
Requires
- php: >=7.0
- ext-json: *
- ext-zlib: *
- guzzlehttp/psr7: ^1.4
- psr/http-message: ^1.0
- psr/log: ^1.0
- react/http: ^1.0
- react/promise: ^2.7
- zendframework/zend-filter: ^2.8
- zendframework/zend-validator: ^2.10
Requires (Dev)
- phpstan/phpstan: ^0.12.2
- phpunit/phpunit: ^6.5
Suggests
- cboden/ratchet: Websocket server
- wyrihaximus/react-http-middleware-session: session handling
README
This is a small http server framework built on top of React HTTP.
This framework is designed to build quick proofs of concepts.
It is not mature enough to run in production environments, because:
- it still contains synchronous blocking code
- it lacks a dependency (ioc) /configuration management
License
MIT
Features
Most of features are directly inherited from PHP React HTTP
- Middleware based
- see https://github.com/reactphp/http/wiki/Middleware for interesting middlewares you can add to this library
- Highly customizable
- PSR-7 messages
- Basic routing
- Basic PSR-3 logging
- Static files serving
- Let you focus on your service logic, not building a HTTP response (boooring)
- Just return
arrays
orobjects
in your route handlers, that's it:
function (ServerRequestInterface $request) { return ['hello' => 'world']; }
- Just return
Install
Install with composer:
composer require phpbg/mini-httpd
Examples
See example
folder
bare-minimal-json-server.php
shows the very minimal setup for json renderingfull-featured-server.php
shows a full setup with:- Static files serving
- Route redirection examples
- Automatic PHTML renderer features and suggested layout
- Accessing request params with proper validation / filtering
There is also a complete example that integrates with ratchet Websockets here: https://github.com/phpbg/mini-httpd-ratchet
TODO
- writing tests