An open API service indexing awesome lists of open source software.

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

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 );
//
```