https://github.com/dionchaika/router
The PSR RESTful Router
https://github.com/dionchaika/router
http http-factory http-message http-server-handler http-server-middleware php psr psr-15 psr-17 psr-7 rest router
Last synced: 27 days ago
JSON representation
The PSR RESTful Router
- Host: GitHub
- URL: https://github.com/dionchaika/router
- Owner: dionchaika
- License: mit
- Created: 2019-04-30T16:47:39.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-30T16:13:56.000Z (over 6 years ago)
- Last Synced: 2026-01-14T15:41:44.876Z (28 days ago)
- Topics: http, http-factory, http-message, http-server-handler, http-server-middleware, php, psr, psr-15, psr-17, psr-7, rest, router
- Language: PHP
- Size: 56.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Router
The PSR RESTful Router Library
## Installation
```bash
composer require dionchaika/router:dev-master
```
```php
Options -MultiViews -Indexes
RewriteEngine On
RewriteCond %{HTTP:Authorization} .
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
```
## Configuration
```php
match(ServerRequest::createFromGlobals()));
```
## Basic usage
1. Registering routes:
```php
get('/', function ($request) {
return (new ResponseFactory)
->createPlainTextResponse('Welcome!');
});
//
// Allowed request methods:
//
// $router->get( pattern, handler );
// $router->put( pattern, handler );
// $router->head( pattern, handler );
// $router->post( pattern, handler );
// $router->patch( pattern, handler );
// $router->delete( pattern, handler );
// $router->options( pattern, handler );
//
```