2017 © Pedro Peláez
 

library httprouter

An extended implementation of the routing class, dealing with an HTTP abstraction and middleware.

image

vakata/httprouter

An extended implementation of the routing class, dealing with an HTTP abstraction and middleware.

  • Thursday, October 27, 2016
  • by vakata
  • Repository
  • 1 Watchers
  • 1 Stars
  • 46 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

httprouter

Latest Version on Packagist ![Software License][ico-license] Build Status Code Climate ![Tests Coverage][ico-cc-coverage], (*1)

An extended implementation of the routing class, dealing with an HTTP abstraction and middleware., (*2)

Install

Via Composer, (*3)

``` bash $ composer require vakata/httprouter, (*4)


## Usage ``` php // create an instance $httprouter = new \vakata\httprouter\HttpRouter(); $httprouter ->get('/', function () { echo 'homepage'; }) ->get('/profile', function () { echo 'user profile'; }) ->group('/books/', function ($httprouter) { // specify a prefix $httprouter ->get('read/{i:id}', function ($matches) { // this method uses a named placeholder // when visiting /books/read/10 matches will contain: var_dump($matches); // 0 => books, 1 => read, 2 => 10, id => 10 // placeholders are wrapped in curly braces {...} and can be: // - i - an integer // - a - any letter (a-z) // - h - any letter or integer // - * - anything (up to the next slash (/)) // - ** - anything (to the end of the URL) // placeholders can be named too by using the syntax: // {placeholder:name} // placeholders can also be optional // {?optional} }) // for advanced users - you can use any regex as a placeholder: ->get('{(delete|update):action}/{(\d+):id}', function ($matches) { }) // you can also use any HTTP verb ->post('delete/{i:id}', function ($matches) { }) }) // you can also bind multiple HTTP verbs in one go ->add(['GET', 'HEAD'], '/path', function () { }); // there is no need to chain the method calls - this works too: $httprouter->post('123', function () { }); $httprouter->post('456', function () { }); // you finally run the httprouter try { $httprouter->run( parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), $_SERVER['REQUEST_METHOD'] ); } catch (\vakata\router\RouterNotFoundException $e) { // thrown if no matching route is found }

Read more in the API docs, (*5)

Testing

bash $ composer test, (*6)

Contributing

Please see CONTRIBUTING for details., (*7)

Security

If you discover any security related issues, please email github@vakata.com instead of using the issue tracker., (*8)

Credits

License

The MIT License (MIT). Please see License File for more information., (*9)

The Versions

27/10 2016

dev-master

9999999-dev https://github.com/vakata/httprouter

An extended implementation of the routing class, dealing with an HTTP abstraction and middleware.

  Sources   Download

MIT

The Requires

 

The Development Requires

router vakata

27/10 2016

3.0.3

3.0.3.0 https://github.com/vakata/httprouter

An extended implementation of the routing class, dealing with an HTTP abstraction and middleware.

  Sources   Download

MIT

The Requires

 

The Development Requires

router vakata

22/07 2016

3.0.2

3.0.2.0 https://github.com/vakata/httprouter

An extended implementation of the routing class, dealing with an HTTP abstraction and middleware.

  Sources   Download

MIT

The Requires

 

The Development Requires

router vakata

16/07 2016

3.0.1

3.0.1.0 https://github.com/vakata/httprouter

An extended implementation of the routing class, dealing with an HTTP abstraction and middleware.

  Sources   Download

MIT

The Requires

 

The Development Requires

router vakata

15/07 2016

3.0.0

3.0.0.0 https://github.com/vakata/httprouter

An extended implementation of the routing class, dealing with an HTTP abstraction and middleware.

  Sources   Download

MIT

The Requires

 

The Development Requires

router vakata

15/07 2016

2.0.0

2.0.0.0 https://github.com/vakata/httprouter

An extended implementation of the routing class, dealing with an HTTP abstraction and middleware.

  Sources   Download

MIT

The Requires

 

The Development Requires

router vakata

02/06 2016

1.0.4

1.0.4.0 https://github.com/vakata/httprouter

An extended implementation of the routing class, dealing with an HTTP abstraction and middleware.

  Sources   Download

MIT

The Requires

 

The Development Requires

router vakata

02/06 2016

1.0.3

1.0.3.0 https://github.com/vakata/httprouter

An extended implementation of the routing class, dealing with an HTTP abstraction and middleware.

  Sources   Download

MIT

The Requires

 

The Development Requires

router vakata

17/04 2016

1.0.2

1.0.2.0 https://github.com/vakata/httprouter

An extended implementation of the routing class, dealing with an HTTP abstraction and middleware.

  Sources   Download

MIT

The Requires

 

The Development Requires

router vakata

17/04 2016

1.0.1

1.0.1.0 https://github.com/vakata/httprouter

An extended implementation of the routing class, dealing with an HTTP abstraction and middleware.

  Sources   Download

MIT

The Requires

 

The Development Requires

router vakata

17/04 2016

1.0.0

1.0.0.0 https://github.com/vakata/httprouter

An extended implementation of the routing class, dealing with an HTTP abstraction and middleware.

  Sources   Download

MIT

The Requires

 

The Development Requires

router vakata