Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/00f100/fcphp-route

Package to manipulate routes
https://github.com/00f100/fcphp-route

fcphp http php7 php72 request route

Last synced: about 2 months ago
JSON representation

Package to manipulate routes

Awesome Lists containing this project

README

        

# FcPHP Route

Package do manage routes into FcPhp

[![Build Status](https://travis-ci.org/00F100/fcphp-route.svg?branch=master)](https://travis-ci.org/00F100/fcphp-route) [![codecov](https://codecov.io/gh/00F100/fcphp-route/branch/master/graph/badge.svg)](https://codecov.io/gh/00F100/fcphp-route) [![Total Downloads](https://poser.pugx.org/00F100/fcphp-route/downloads)](https://packagist.org/packages/00F100/fcphp-route)

## How to install

Composer:
```sh
$ composer require 00f100/fcphp-route
```

or composer.json
```json
{
"require": {
"00f100/fcphp-route": "*"
}
}
```

## How to use

After match route (same 404, 403) return instance of [FcPhp\Route\Entity](https://github.com/00F100/fcphp-route/blob/master/src/Interfaces/IEntity.php)

```php
match('GET', 'v1/users/10');

// Print: FcPhp\Route\Entity
echo get_class($match);

// Print: 200
echo $match->getStatusCode();
```

##### Callback's

```php
callback('initCallback', function(array $routes) {

// Your code here ...

});

// Match route
$instance->callback('matchCallback', function(array $routes, string $method, string $route, array $entity, IEntity $routeEntity) {

// Your code here ...

});

// Route not found
$instance->callback('notFoundCallback', function(array $routes, string $method, string $route, array $entity = [], IEntity $routeEntity = null) {

// Your code here ...

});
```

##### [FcPhp\Route\Entity](https://github.com/00F100/fcphp-route/blob/master/src/Interfaces/IEntity.php)

```php