https://github.com/mnavarrocarter/amp-http-router
An asynchronous HTTP routing engine for Amp based applications
https://github.com/mnavarrocarter/amp-http-router
amphp amphp-http express http middleware router
Last synced: 8 months ago
JSON representation
An asynchronous HTTP routing engine for Amp based applications
- Host: GitHub
- URL: https://github.com/mnavarrocarter/amp-http-router
- Owner: mnavarrocarter
- Created: 2020-08-28T16:21:05.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-05T15:44:12.000Z (over 5 years ago)
- Last Synced: 2025-07-18T02:17:56.784Z (8 months ago)
- Topics: amphp, amphp-http, express, http, middleware, router
- Language: PHP
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-amphp - mnavarrocarter/amp-http-router - An asynchronous HTTP routing engine for Amp based applications (HTTP / Routing)
README
AMP HTTP Router
===============
A high performance routing engine that handles requests for an Amp HTTP Server inspired in
Express JS.
## Installation
```bash
composer require mnavarrocarter/amp-http-router
```
## Quick Start
```php
getParam('id');
return html(sprintf('The user id is %s', $id));
}
$router = Router::create();
$router->get('/', handleFunc('homepage'));
$router->get('/users/:id', handleFunc('findUser'));
Amp\Loop::run(fn() => yield listenAndServe('0.0.0.0:8000', $router));
```
### Router Composition
You can have multiple routers mounted to different paths for more efficient
routing:
```php
mount('/api', $api);
```