Fast request router for PHP

Related tags

Routers FastRoute
Overview

FastRoute - Fast request router for PHP

Build Status

This library provides a fast implementation of a regular expression based router. Blog post explaining how the implementation works and why it is fast.

Install

To install with composer:

composer require nikic/fast-route

Requires PHP 7.1 or newer.

Usage

Here's a basic usage example:

<?php

require '/path/to/vendor/autoload.php';

$dispatcher = FastRoute\simpleDispatcher(function(FastRoute\RouteCollector $r) {
    $r->addRoute('GET', '/users', 'get_all_users_handler');
    // {id} must be a number (\d+)
    $r->addRoute('GET', '/user/{id:\d+}', 'get_user_handler');
    // The /{title} suffix is optional
    $r->addRoute('GET', '/articles/{id:\d+}[/{title}]', 'get_article_handler');
});

// Fetch method and URI from somewhere
$httpMethod = $_SERVER['REQUEST_METHOD'];
$uri = $_SERVER['REQUEST_URI'];

// Strip query string (?foo=bar) and decode URI
if (false !== $pos = strpos($uri, '?')) {
    $uri = substr($uri, 0, $pos);
}
$uri = rawurldecode($uri);

$routeInfo = $dispatcher->dispatch($httpMethod, $uri);
switch ($routeInfo[0]) {
    case FastRoute\Dispatcher::NOT_FOUND:
        // ... 404 Not Found
        break;
    case FastRoute\Dispatcher::METHOD_NOT_ALLOWED:
        $allowedMethods = $routeInfo[1];
        // ... 405 Method Not Allowed
        break;
    case FastRoute\Dispatcher::FOUND:
        $handler = $routeInfo[1];
        $vars = $routeInfo[2];
        // ... call $handler with $vars
        break;
}

Defining routes

The routes are defined by calling the FastRoute\simpleDispatcher() function, which accepts a callable taking a FastRoute\RouteCollector instance. The routes are added by calling addRoute() on the collector instance:

$r->addRoute($method, $routePattern, $handler);

The $method is an uppercase HTTP method string for which a certain route should match. It is possible to specify multiple valid methods using an array:

// These two calls
$r->addRoute('GET', '/test', 'handler');
$r->addRoute('POST', '/test', 'handler');
// Are equivalent to this one call
$r->addRoute(['GET', 'POST'], '/test', 'handler');

By default the $routePattern uses a syntax where {foo} specifies a placeholder with name foo and matching the regex [^/]+. To adjust the pattern the placeholder matches, you can specify a custom pattern by writing {bar:[0-9]+}. Some examples:

// Matches /user/42, but not /user/xyz
$r->addRoute('GET', '/user/{id:\d+}', 'handler');

// Matches /user/foobar, but not /user/foo/bar
$r->addRoute('GET', '/user/{name}', 'handler');

// Matches /user/foo/bar as well
$r->addRoute('GET', '/user/{name:.+}', 'handler');

Custom patterns for route placeholders cannot use capturing groups. For example {lang:(en|de)} is not a valid placeholder, because () is a capturing group. Instead you can use either {lang:en|de} or {lang:(?:en|de)}.

Furthermore parts of the route enclosed in [...] are considered optional, so that /foo[bar] will match both /foo and /foobar. Optional parts are only supported in a trailing position, not in the middle of a route.

// This route
$r->addRoute('GET', '/user/{id:\d+}[/{name}]', 'handler');
// Is equivalent to these two routes
$r->addRoute('GET', '/user/{id:\d+}', 'handler');
$r->addRoute('GET', '/user/{id:\d+}/{name}', 'handler');

// Multiple nested optional parts are possible as well
$r->addRoute('GET', '/user[/{id:\d+}[/{name}]]', 'handler');

// This route is NOT valid, because optional parts can only occur at the end
$r->addRoute('GET', '/user[/{id:\d+}]/{name}', 'handler');

The $handler parameter does not necessarily have to be a callback, it could also be a controller class name or any other kind of data you wish to associate with the route. FastRoute only tells you which handler corresponds to your URI, how you interpret it is up to you.

Shortcut methods for common request methods

For the GET, POST, PUT, PATCH, DELETE and HEAD request methods shortcut methods are available. For example:

$r->get('/get-route', 'get_handler');
$r->post('/post-route', 'post_handler');

Is equivalent to:

$r->addRoute('GET', '/get-route', 'get_handler');
$r->addRoute('POST', '/post-route', 'post_handler');

Route Groups

Additionally, you can specify routes inside of a group. All routes defined inside a group will have a common prefix.

For example, defining your routes as:

$r->addGroup('/admin', function (RouteCollector $r) {
    $r->addRoute('GET', '/do-something', 'handler');
    $r->addRoute('GET', '/do-another-thing', 'handler');
    $r->addRoute('GET', '/do-something-else', 'handler');
});

Will have the same result as:

$r->addRoute('GET', '/admin/do-something', 'handler');
$r->addRoute('GET', '/admin/do-another-thing', 'handler');
$r->addRoute('GET', '/admin/do-something-else', 'handler');

Nested groups are also supported, in which case the prefixes of all the nested groups are combined.

Caching

The reason simpleDispatcher accepts a callback for defining the routes is to allow seamless caching. By using cachedDispatcher instead of simpleDispatcher you can cache the generated routing data and construct the dispatcher from the cached information:

<?php

$dispatcher = FastRoute\cachedDispatcher(function(FastRoute\RouteCollector $r) {
    $r->addRoute('GET', '/user/{name}/{id:[0-9]+}', 'handler0');
    $r->addRoute('GET', '/user/{id:[0-9]+}', 'handler1');
    $r->addRoute('GET', '/user/{name}', 'handler2');
}, [
    'cacheFile' => __DIR__ . '/route.cache', /* required */
    'cacheDisabled' => IS_DEBUG_ENABLED,     /* optional, enabled by default */
]);

The second parameter to the function is an options array, which can be used to specify the cache file location, among other things.

Dispatching a URI

A URI is dispatched by calling the dispatch() method of the created dispatcher. This method accepts the HTTP method and a URI. Getting those two bits of information (and normalizing them appropriately) is your job - this library is not bound to the PHP web SAPIs.

The dispatch() method returns an array whose first element contains a status code. It is one of Dispatcher::NOT_FOUND, Dispatcher::METHOD_NOT_ALLOWED and Dispatcher::FOUND. For the method not allowed status the second array element contains a list of HTTP methods allowed for the supplied URI. For example:

[FastRoute\Dispatcher::METHOD_NOT_ALLOWED, ['GET', 'POST']]

NOTE: The HTTP specification requires that a 405 Method Not Allowed response include the Allow: header to detail available methods for the requested resource. Applications using FastRoute should use the second array element to add this header when relaying a 405 response.

For the found status the second array element is the handler that was associated with the route and the third array element is a dictionary of placeholder names to their values. For example:

/* Routing against GET /user/nikic/42 */

[FastRoute\Dispatcher::FOUND, 'handler0', ['name' => 'nikic', 'id' => '42']]

Overriding the route parser and dispatcher

The routing process makes use of three components: A route parser, a data generator and a dispatcher. The three components adhere to the following interfaces:

<?php

namespace FastRoute;

interface RouteParser {
    public function parse($route);
}

interface DataGenerator {
    public function addRoute($httpMethod, $routeData, $handler);
    public function getData();
}

interface Dispatcher {
    const NOT_FOUND = 0, FOUND = 1, METHOD_NOT_ALLOWED = 2;

    public function dispatch($httpMethod, $uri);
}

The route parser takes a route pattern string and converts it into an array of route infos, where each route info is again an array of it's parts. The structure is best understood using an example:

/* The route /user/{id:\d+}[/{name}] converts to the following array: */
[
    [
        '/user/',
        ['id', '\d+'],
    ],
    [
        '/user/',
        ['id', '\d+'],
        '/',
        ['name', '[^/]+'],
    ],
]

This array can then be passed to the addRoute() method of a data generator. After all routes have been added the getData() of the generator is invoked, which returns all the routing data required by the dispatcher. The format of this data is not further specified - it is tightly coupled to the corresponding dispatcher.

The dispatcher accepts the routing data via a constructor and provides a dispatch() method, which you're already familiar with.

The route parser can be overwritten individually (to make use of some different pattern syntax), however the data generator and dispatcher should always be changed as a pair, as the output from the former is tightly coupled to the input of the latter. The reason the generator and the dispatcher are separate is that only the latter is needed when using caching (as the output of the former is what is being cached.)

When using the simpleDispatcher / cachedDispatcher functions from above the override happens through the options array:

<?php

$dispatcher = FastRoute\simpleDispatcher(function(FastRoute\RouteCollector $r) {
    /* ... */
}, [
    'routeParser' => 'FastRoute\\RouteParser\\Std',
    'dataGenerator' => 'FastRoute\\DataGenerator\\MarkBased',
    'dispatcher' => 'FastRoute\\Dispatcher\\MarkBased',
]);

The above options array corresponds to the defaults. By replacing MarkBased with GroupCountBased you could switch to a different dispatching strategy.

A Note on HEAD Requests

The HTTP spec requires servers to support both GET and HEAD methods:

The methods GET and HEAD MUST be supported by all general-purpose servers

To avoid forcing users to manually register HEAD routes for each resource we fallback to matching an available GET route for a given resource. The PHP web SAPI transparently removes the entity body from HEAD responses so this behavior has no effect on the vast majority of users.

However, implementers using FastRoute outside the web SAPI environment (e.g. a custom server) MUST NOT send entity bodies generated in response to HEAD requests. If you are a non-SAPI user this is your responsibility; FastRoute has no purview to prevent you from breaking HTTP in such cases.

Finally, note that applications MAY always specify their own HEAD method route for a given resource to bypass this behavior entirely.

Credits

This library is based on a router that Levi Morrison implemented for the Aerys server.

A large number of tests, as well as HTTP compliance considerations, were provided by Daniel Lowrey.

Comments
  • Add the convenience to create the same route for two or more http methods

    Add the convenience to create the same route for two or more http methods

    Add the convenience to create the same route for two or more http methods

    For example:

    You can add a route passing a string

    $r->addRoute('POST', '/xml/{name}', 'xml');
    $r->addRoute('GET', '/xml/{name}', 'xml');
    

    Or passing an array of methods (the result in this case will be the same):

    $r->addRoute(array('GET', 'POST'), '/xml/{name}', 'xml');
    

    Note: You can continue to pass the strings "POST", "GET", "DELETE" and "PUT".

    opened by byjg 22
  • Less information

    Less information

    This script has less information about using it. Where is info about .htaccess? Why in basic usage is: "$r->addRoute('GET', '/user/{id:\d+}/{name}', 'handler2');" this is not working when anyone using subfolder as root of script. because router don't expecting subfolder/user/12/mario.

    opened by MESWEB 13
  • Dispatcher result refactored, RouteCollector to RouteCollection renamed

    Dispatcher result refactored, RouteCollector to RouteCollection renamed

    • The dispatcher returns now a result object (I don't mind discussing the method names)
      • ArrayAccess is provided for backward compatibility.
    • The result object contains now always a route object, this is a preparation for more changes related to give this object more meaning and power.
    • RouteCollector renamed to RouteCollection.
      • This would break BC if somebody uses the class directly but renaming it should no big deal at all. An alias could provided as well.
    • Refactored data generators
    opened by burzum 12
  • Introduce cache drivers

    Introduce cache drivers

    Fixes #140

    This provides a caching interface and implementations for the most common drivers (filesystem and APCu). Users can create their own implementation of the interface to support PSR-6/PSR-16/anything else.

    enhancement 
    opened by lcobucci 11
  • Allow overriding routes with the same name and method

    Allow overriding routes with the same name and method

    At the moment, if we try to re-register a route with the same name and method, we get the following error:

    'Cannot register two routes matching "%s" for method "%s"'

    This makes it difficult to design an extendable application. For example, I'd like to develop a plugin system for my web application, where plugins can define routes that override the routes defined in the core application.

    It would be better if FastRoute simply replaced the previously defined handler with the new handler in these cases. Perhaps there could even be some global option allowOverride that controls this behavior, to remain backwards-compatible.

    As it stands, I am completely stalled in the development of my application because of this limitation.

    opened by alexweissman 11
  • HHI: Change the options arrays for dispatchers to shapes

    HHI: Change the options arrays for dispatchers to shapes

    It's currently not possible to specify the cacheDisabled option, as it is a bool. To fix, actually define the acceptable options and their types.

    HHVM allows nullable shape fields to not be specified.

    This is BC breaking, as it must now be passed in as a shape instead of an array.

    A non-BC-breaking alternative would be to change the array to array<string, mixed> from array<string, string>

    opened by fredemmott 11
  • Optional Items in RouteCollector

    Optional Items in RouteCollector

    Hello @nikic Thank you for the awesome Router! I was wondering if there is a way to have slightly 'cleaner' routes, by using optional elements in the addRoute call? Example: Right now I have $r->addRoute('GET', '/users/{id:[0-9]+}', 'myfunction'); // slash-less $r->addRoute('GET', '/users/{id:[0-9]+}/', 'myfunction'); // with a slash!

    is there a way to combine these with something like $r->addRoute('GET', '/users/{id:[0-9]+}/?', 'myfunction'); // "?" indicates optional prev token "/" or $r->addRoute('GET', '/users/{id:[0-9]+}/{'commentid:[0-9]+'}?', 'myfunction'); // ? indicates optional prev token " {'commentid:[0-9]+'} "

    thanks!

    opened by lmon 11
  • Route cache is never invalidated

    Route cache is never invalidated

    When I create a cachedDispatcher, it caches the data to a file as expected. But when I add a new route it's not added to the cache. Looking at the code I don't see anything that expires the cache (e.g. after X minutes/hours).

    Is there a different method of working that I am missing here?

    opened by svivian 10
  • Allow more complex routes

    Allow more complex routes

    Migrating an old application (from @slimphp version 2) to FastRoute, I can't find a way to obtain the same behaviour of this match:

    (/:optionalPrefix)(/(:language/)(:controller(/:id/:hex)(/:property(/:subId/:subHex))(/:more+)))
    

    Each of the keywords (except more) has its own regex for matching.

    With FastRoute I tried something (simpler) like:

    /{controller:[a-z-]{3,}}[[/[{id:\d+}/{hex:[a-f0-9]{32,40}}][/[{property:[a-z-]{3,}}[/{more:.*}]]]]]
    

    and I've got a FastRoute\BadRouteException with message

    Optional segments can only occur at the end of a route

    The idea (of that try) is to allow all these routes:

    /
    /controller
    /controller/id/hex
    /controller/property
    /controller/id/hex/property
    

    Trying this, instead

    /{controller:[a-z-]{3,}}[/[{id:\d+}/{hex:[a-f0-9]{32,40}}[/[{property:[a-z-]{3,}}[/{more:.*}]]]]]
    

    it passes, but it's not what I had in mind, because it doesn't match /controller/property

    Am I missing something? Or is actually a limitation?

    Thanks.

    opened by alessandroraffa 9
  • Autoload performance problems

    Autoload performance problems

    Hi, As I see, you have used PHP auto loading in the project. That's cool in terms of code beauty but it is a huge performance drawback. Specially, the excessive use of numerous files, each for a small class. IO is a bottleneck in applications and loading several small files is usually heavier than loading one big file. And worse than that, auto loaded files can not be cached by PHP OP Code cache tools like eAccelerator or APC since they are fully runtime. I suggest providing a single file, compiled version of your library. Or let auto loading be optional like HTMLPurifier. I mean, we choose FASTroute for being fast, let's not spoil the amount of work you did to optimize the stuff, by a huge start up time. I think considering library loading time, you might lose the benchmark to Pux! Anyway, thanks for your great work...

    opened by creativefctr 9
  • POST route + custom placeholder pattern is being overridden by GET route + default placeholder pattern

    POST route + custom placeholder pattern is being overridden by GET route + default placeholder pattern

    In the code below, the GET route is overriding the POST route whenever I use a custom pattern. However, if I try the same POST route with the default pattern, it does correctly match.

    <?php
    
    require_once './vendor/autoload.php';
    
    $dispatcher = FastRoute\simpleDispatcher(function(FastRoute\RouteCollector $r) {
        $r->addRoute('GET',  '/user/{name}', 'GET with default placeholder pattern');
        $r->addRoute('POST', '/user/{name:[a-z]+}', 'POST with custom placeholder pattern');
    
        // This route correctly matches if uncommented
        // $r->addRoute('POST', '/user/{name}', 'POST with default placeholder pattern');
    });
    
    function handle($routeInfo) {
        print_r($routeInfo);
        echo "\n";
    }
    
    handle($dispatcher->dispatch('GET', '/user/bob'));
    handle($dispatcher->dispatch('POST', '/user/fred')); // does not work
    
    opened by msheakoski 9
  • why fastRoute not  working in my server

    why fastRoute not working in my server

    hello my local project work but when i am uploading code to server nothing work .

    i.e : this way localhost:9000/hello works but this one http://api.domaine.com/hello does not working

    could someone help?

    thank you

    question 
    opened by pabios 4
  • Suport optinal middle segment

    Suport optinal middle segment

    Hello, They could accept this PR (#179), it would be very useful for example to create file managers, not forcing to always have a path from the base path.

    In the current situation the url would have to be like this

    /file/{path:[A-Za-z0-9\/]+}/{file:[\w,\s-]+\.[A-Za-z]{3,4}}

    with this expression I can make these routes

    files/mandatory-folder/file.jpg
    files/obligatory-folder/another-folder/file.jpg
    

    but i can't do

    files/file.jpg

    since path is always required.

    Thanks for the work.

    opened by GoldraK 0
  • Return variable as array

    Return variable as array

    Is there a way to get variables returned in an array instead of individually.. Like so Instead of $app->get('/nanna/{name}[/{id}[/{product}[/{size}]]]', function($name, $id, $product, $size ) {

    Like so $app->get('/nanna/{name}[/{id}[/{product}[/{size}]]]', function(array $params ) {

    And then access in $params ( $params['name'], $params[''id] etcetera) , that would be very useful no need to named variable in route setup et al and so on ..

    Currently using Leocavalcante/siler Route and works like this.. but is not maintained anymore and need to use FastRoute (perhaps).. (also multiple optional middle segments AS well which I find useful)

    :)

    opened by lookingdown 0
  • Implement new dispatcher

    Implement new dispatcher

    More info will be coming soon...

    • [ ] Improve data generation performance
    • [ ] Generate multiple regexes instead of only 1 (using 2.5k char as limit - according to some tests that's the best regex size for handling first and last scenarios on a collection of over 4k routes)
    • [ ] Fix broken test
    enhancement 
    opened by lcobucci 4
Releases(v1.3.0)
  • v1.3.0(Feb 13, 2018)

    • Improve type usage in doc comments.
    • Switch coding style to PSR-2.
    • Mark shape keys in FastRoute.hhi as optional. This adds support for HHVM >= 3.23 and removes support for HHVM < 3.23.
    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(Feb 5, 2017)

  • v1.1.0(Dec 27, 2016)

    Fixed

    • If the cacheDisabled option is enabled, the cache file is no longer written. Previously it was not read, but still written. (#114)

    Added

    • Added convenience methods get(), post(), put(), delete(), patch() and head() to the RouteCollector. (#109)
    Source code(tar.gz)
    Source code(zip)
  • v1.0.1(Jun 17, 2016)

  • v1.0.0(Apr 30, 2016)

    This is a re-release of version 0.8.0 without code changes. Given the number of dependent projects there should be a formally stable release :)

    Source code(tar.gz)
    Source code(zip)
  • v0.8.0(Mar 25, 2016)

    • Fixed fallback from HEAD to GET if dynamic HEAD routes are defined.
    • First check all HEAD routes before attempting a GET fallback.
    • Add support for hyphens in placeholder names.
    • (Experimental.) Add support for fallback routes that match any method. These are specified using a * method and matched after all other routes.
    Source code(tar.gz)
    Source code(zip)
  • v0.7.0(Dec 20, 2015)

    • Add HHI file for Hack typechecking support. The HHI file requires HHVM 3.9 or newer.
    • Fix support for empty routes.
    • Improve error message if optional part is not at the end of a route.
    Source code(tar.gz)
    Source code(zip)
  • v0.6.0(Jun 24, 2015)

    Added support for trailing optional segments, for example the route

    $r->addRoute('GET', '/foo[/{bar}[/{baz}]]', 'handler');
    

    is equivalent to the three routes

    $r->addRoute('GET', '/foo', 'handler');
    $r->addRoute('GET', '/foo/{bar}', 'handler');
    $r->addRoute('GET', '/foo/{bar}/{baz}', 'handler');
    

    As a result of this additional the output format for RouteParser was changed to add another array level, which may need to be accounted for if you use a custom parser.

    Source code(tar.gz)
    Source code(zip)
  • v0.5.0(May 22, 2015)

    • Fixed fallback of static routes to dynamic routes with different allowed HTTP methods. (#50)
    • Added routeCollector option to dispatcher functions. (#40)
    • The simpleDispatcher() and cachedDispatcher() functions will now only be defined if they do not yet exist, resolving some autoloading issues. (#39)
    • Capturing groups inside placeholder regular expressions will now be detected and explicitly forbidden. (#34)

    This release changes the structure of the cached data (if cachedDispatcher is used), so the cache file should be removed after the update.

    Source code(tar.gz)
    Source code(zip)
  • v0.4.0(Mar 8, 2015)

    This release adds support for registering a route for multiple HTTP methods at the same time, by passing an array for the method parameter of RouteCollector::addRoute(). For example:

    /** @var RouteCollector $r */
    $r->addRoute(['GET', 'POST'], '/foo/{bar}', 'handlerForGetAndPost');
    
    // This is equivalent to:
    $r->addRoute('GET', '/foo/{bar}', 'handlerForGetAndPost');
    $r->addRoute('POST', '/foo/{bar}', 'handlerForGetAndPost');
    
    
    Source code(tar.gz)
    Source code(zip)
  • v0.3.0(Nov 26, 2014)

    This release fixes a routing bug, which could occur if two non-disjoint routes for different HTTP methods are defined:

    $dispatcher = FastRoute\simpleDispatcher(function(FastRoute\RouteCollector $r) {
        $r->addRoute('GET',  '/user/{name}', 'GET with default placeholder pattern');
        $r->addRoute('POST', '/user/{name:[a-z]+}', 'POST with custom placeholder pattern');
    });
    

    A request to POST /user/foobar was previously rejected with 405 Method Not Supported and is now correctly matched.

    For more information see #25.

    This release changes the structure of the cached data (if cachedDispatcher is used), so the cache file should be removed after the update.

    Source code(tar.gz)
    Source code(zip)
Owner
Nikita Popov
Nikita Popov
klein.php is a fast & flexible router for PHP 5.3+

Klein.php klein.php is a fast & flexible router for PHP 5.3+ Flexible regular expression routing (inspired by Sinatra) A set of boilerplate methods fo

null 2.6k Jan 7, 2023
Pux is a fast PHP Router and includes out-of-box controller tools

Pux Pux is a faster PHP router, it also includes out-of-box controller helpers. 2.0.x Branch Build Status (This branch is under development) Benchmark

Yo-An Lin 1.3k Dec 21, 2022
:tada: Release 2.0 is released! Very fast HTTP router for PHP 7.1+ (incl. PHP8 with attributes) based on PSR-7 and PSR-15 with support for annotations and OpenApi (Swagger)

HTTP router for PHP 7.1+ (incl. PHP 8 with attributes) based on PSR-7 and PSR-15 with support for annotations and OpenApi (Swagger) Installation compo

Sunrise // PHP 151 Jan 5, 2023
PhpRouter is a powerful, lightweight, and very fast HTTP URL router for PHP projects.

PhpRouter PhpRouter is a powerful, lightweight, and very fast HTTP URL router for PHP projects. Some of the provided features: Route parameters Predef

Milad Rahimi 152 Dec 28, 2022
Flight routing is a simple, fast PHP router that is easy to get integrated with other routers.

The PHP HTTP Flight Router divineniiquaye/flight-routing is a HTTP router for PHP 7.1+ based on PSR-7 and PSR-15 with support for annotations, created

Divine Niiquaye Ibok 16 Nov 1, 2022
Simple, fast and yet powerful PHP router that is easy to get integrated and in any project.

Simple, fast and yet powerful PHP router that is easy to get integrated and in any project. Heavily inspired by the way Laravel handles routing, with both simplicity and expand-ability in mind.

Simon Sessingø 472 Jan 4, 2023
A lightweight and fast router for PHP

Piko Router A lightweight and blazing fast router (see benchmarks) using a radix trie to store dynamic routes. This router maps routes to user defined

Piko framework 62 Dec 27, 2022
PHPRouter is an easy-to-use, fast, and flexible PHP router package with express-style routing.

PHP-Router is a modern, fast, and adaptable composer package that provides express-style routing in PHP without a framework.

Ayodeji O. 4 Oct 20, 2022
A fast & flexible router

Klein.php klein.php is a fast & flexible router for PHP 5.3+ Flexible regular expression routing (inspired by Sinatra) A set of boilerplate methods fo

null 2.6k Dec 28, 2022
A web router implementation for PHP.

Aura.Router Powerful, flexible web routing for PSR-7 requests. Installation and Autoloading This package is installable and PSR-4 autoloadable via Com

Aura for PHP 469 Jan 1, 2023
:bird: Simple PHP router

Macaw Macaw is a simple, open source PHP router. It's super small (~150 LOC), fast, and has some great annotated source code. This class allows you to

Noah Buscher 895 Dec 21, 2022
Toro is a PHP router for developing RESTful web applications and APIs.

Toro Toro is a PHP router for developing RESTful web applications and APIs. It is designed for minimalists who want to get work done. Quick Links Offi

Kunal Anand 1.2k Dec 27, 2022
A lightweight and simple object oriented PHP Router

bramus/router A lightweight and simple object oriented PHP Router. Built by Bram(us) Van Damme (https://www.bram.us) and Contributors Features Support

Bramus! 935 Jan 1, 2023
A simple PHP Router

Panda Router Description the panda-router is a small alternative PHP router that can be used for small projects. With this router you can use differen

Jan Behrens 1 Dec 27, 2021
Thruway - an open source client and router implementation of WAMP (Web Application Messaging Protocol), for PHP.

PHP Client and Router Library for Autobahn and WAMP (Web Application Messaging Protocol) for Real-Time Application Messaging

Voryx 661 Nov 14, 2022
A lightweight and very basic PHP router.

Katya A lightweight PHP router Configuration Para servidor Apache, en el directorio del proyecto crea y edita un archivo .htaccess con lo siguiente: <

Luis RodrĂ­guez 0 Apr 4, 2022
A PHP Router Package

Router A PHP Router Package Basic Concepts A router package is a utility that, once all http requests are redirected to an entry point, can configure

null 0 Aug 26, 2022
The simple PHP router

Macaw Macaw is a simple, open source PHP router. It's super small (~150 LOC), fast, and has some great annotated source code. This class allows you to

Noah Buscher 895 Dec 21, 2022
A router for Amp's HTTP Server.

http-server-router This package provides a routing RequestHandler for Amp's HTTP server based on the request URI and method based on FastRoute. Instal

AMPHP 34 Dec 19, 2022