PhpRouter is a powerful, lightweight, and very fast HTTP URL router for PHP projects.

Overview

Latest Stable Version Total Downloads Build Status Coverage Status License

PhpRouter

PhpRouter is a powerful, lightweight, and very fast HTTP URL router for PHP projects.

Some of the provided features:

  • Route parameters
  • Predefined route parameter patterns
  • Middleware
  • Closure and class controllers/middleware
  • Route groups (by prefix, middleware, and domain)
  • Route naming (and generating route by name)
  • PSR-7 requests and responses
  • Views (simple PHP/HTML views)
  • Multiple (sub)domains (using regex patterns)
  • Custom HTTP methods
  • Integrated with an IoC Container (PhpContainer)
  • Method and constructor auto-injection of Request, Route, Url, etc

The current version requires PHP v7.1 or newer versions including v8.0.

Contents

Versions

Supported versions:

  • v5.x.x
  • v4.x.x

Unsupported versions:

  • v3.x.x
  • v2.x.x
  • v1.x.x

Documentation

Installation

Install Composer and run following command in your project's root directory:

composer require miladrahimi/phprouter "5.*"

Configuration

First of all, you need to configure your webserver to handle all the HTTP requests with a single PHP file like the index.php file. Here you can see sample configurations for NGINX and Apache HTTP Server.

  • NGINX configuration sample:

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
  • Apache .htaccess sample:

    
        
            Options -MultiViews
        
    
        RewriteEngine On
    
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)/$ /$1 [L,R=301]
    
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
    
    

Getting Started

It's so easy to work with PhpRouter! Just take a look at the following example.

  • JSON API Example:

    use MiladRahimi\PhpRouter\Router;
    use Laminas\Diactoros\Response\JsonResponse;
    
    $router = Router::create();
    
    $router->get('/', function () {
        return new JsonResponse(['message' => 'ok']);
    });
    
    $router->dispatch();
  • View Example:

    use MiladRahimi\PhpRouter\Router;
    use MiladRahimi\PhpRouter\View\View
    
    $router = Router::create();
    $router->setupView('/../views');
    
    $router->get('/', function (View $view) {
        return $view->make('profile', ['user' => 'Jack']);
    });
    
    $router->dispatch();

HTTP Methods

The following example illustrates how to declare different routes for different HTTP methods.

use MiladRahimi\PhpRouter\Router;

$router = Router::create();

$router->get('/', function () { /* ... */ });
$router->post('/', function () { /* ... */ });
$router->put('/', function () { /* ... */ });
$router->patch('/', function () { /* ... */ });
$router->delete('/', function () { /* ... */ });

$router->dispatch();

You can use the define() method for other HTTP methods like this example:

use MiladRahimi\PhpRouter\Router;

$router = Router::create();

$router->define('GET', '/', function () { /* ... */ });
$router->define('OPTIONS', '/', function () { /* ... */ });
$router->define('CUSTOM', '/', function () { /* ... */ });

$router->dispatch();

If you don't care about HTTP verbs, you can use the any() method.

use MiladRahimi\PhpRouter\Router;

$router = Router::create();

$router->any('/', function () {
    return 'This is Home! No matter what the HTTP method is!';
});

$router->dispatch();

Controllers

Closure Controllers

use MiladRahimi\PhpRouter\Router;

$router = Router::create();

$router->get('/', function () {
    return 'This is a closure controller!';
});

$router->dispatch();

Class Method Controllers

use MiladRahimi\PhpRouter\Router;

class UsersController
{
    function index()
    {
        return 'Class: UsersController & Method: index';
    }

    function handle()
    {
        return 'Class UsersController.';
    }
}

$router = Router::create();

// Controller: Class=UsersController Method=index()
$router->get('/method', [UsersController::class, 'index']);

// Controller: Class=UsersController Method=handle()
$router->get('/class', UsersController::class);

$router->dispatch();

Route Parameters

A URL might have one or more variable parts like product IDs on a shopping website. We call it a route parameter. You can catch them by controller method arguments like the example below.

get('/welcome/{name?}', function ($name = null) { return 'Welcome ' . ($name ?: 'Dear User'); }); // Optional parameter, Optional / (Slash)! $router->get('/profile/?{user?}', function ($user = null) { return ($user ?: 'Your') . ' profile'; }); // Optional parameter with default value $router->get('/roles/{role?}', function ($role = 'guest') { return "Your role is $role"; }); // Multiple parameters $router->get('/post/{pid}/comment/{cid}', function ($pid, $cid) { return "The comment $cid of the post $pid"; }); $router->dispatch(); ">
use MiladRahimi\PhpRouter\Router;

$router = Router::create();

// Required parameter
$router->get('/post/{id}', function ($id) {
    return "The content of post $id";
});

// Optional parameter
$router->get('/welcome/{name?}', function ($name = null) {
    return 'Welcome ' . ($name ?: 'Dear User');
});

// Optional parameter, Optional / (Slash)!
$router->get('/profile/?{user?}', function ($user = null) {
    return ($user ?: 'Your') . ' profile';
});

// Optional parameter with default value
$router->get('/roles/{role?}', function ($role = 'guest') {
    return "Your role is $role";
});

// Multiple parameters
$router->get('/post/{pid}/comment/{cid}', function ($pid, $cid) {
    return "The comment $cid of the post $pid";
});

$router->dispatch();

Route Parameter Patterns

In default, route parameters can have any value, but you can define regex patterns to limit them.

pattern('id', '[0-9]+'); $router->get('/post/{id}', function (int $id) { /* ... */ }); $router->dispatch(); ">
use MiladRahimi\PhpRouter\Router;

$router = Router::create();

// "id" must be numeric
$router->pattern('id', '[0-9]+');

$router->get('/post/{id}', function (int $id) { /* ... */ });

$router->dispatch();

Requests and Responses

PhpRouter uses laminas-diactoros (formerly known as zend-diactoros) package (v2) to provide PSR-7 request and response objects to your controllers and middleware.

Requests

You can catch the request object in your controllers like this example:

use MiladRahimi\PhpRouter\Router;
use Laminas\Diactoros\ServerRequest;
use Laminas\Diactoros\Response\JsonResponse;

$router = Router::create();

$router->get('/', function (ServerRequest $request) {
    $method  = $request->getMethod();
    $uriPath = $request->getUri()->getPath();
    $headers = $request->getHeaders();
    $queryParameters = $request->getQueryParams();
    $bodyContents    = $request->getBody()->getContents();
    // ...
});

$router->dispatch();

Responses

The example below illustrates the built-in responses.

use Laminas\Diactoros\Response\RedirectResponse;
use MiladRahimi\PhpRouter\Router;
use Laminas\Diactoros\Response\EmptyResponse;
use Laminas\Diactoros\Response\HtmlResponse;
use Laminas\Diactoros\Response\JsonResponse;
use Laminas\Diactoros\Response\TextResponse;

$router = Router::create();

$router->get('/html/1', function () {
    return 'This is an HTML response';
});
$router->get('/html/2', function () {
    return new HtmlResponse('This is also an HTML response', 200);
});
$router->get('/json', function () {
    return new JsonResponse(['error' => 'Unauthorized!'], 401);
});
$router->get('/text', function () {
    return new TextResponse('This is a plain text...');
});
$router->get('/empty', function () {
    return new EmptyResponse(204);
});
$router->get('/redirect', function () {
    return new RedirectResponse('https://miladrahimi.com');
});

$router->dispatch();

Views

You might need to create a classic-style website that uses views. PhpRouter has a simple feature for working with PHP/HTML views. Look at the following example.

use MiladRahimi\PhpRouter\Router;
use MiladRahimi\PhpRouter\View\View

$router = Router::create();

// Setup view feature and set the directory of view files
$router->setupView(__DIR__ . '/../views');

$router->get('/profile', function (View $view) {
    // It looks for a view with path: __DIR__/../views/profile.phtml
    return $view->make('profile', ['user' => 'Jack']);
});

$router->get('/blog/post', function (View $view) {
    // It looks for a view with path: __DIR__/../views/blog/post.phtml
    return $view->make('blog.post', ['post' => $post]);
});

$router->dispatch();

There is also some points:

  • View files must have the ".phtml" extension (e.g. profile.phtml).
  • You can separate directories with . (e.g. blog.post for blog/post.phtml).

View files are pure PHP or mixed with HTML. You should use PHP language with template style in the view files. This is a sample view file:

echo $title ?>h1> <ul> foreach ($posts as $post): ?> <li> echo $post['content'] ?>li> endforeach ?> ul>

Route Groups

You can categorize routes into groups. The groups can have common attributes like middleware, domain, or prefix. The following example shows how to group routes:

use MiladRahimi\PhpRouter\Router;

$router = Router::create();

// A group with uri prefix
$router->group(['prefix' => '/admin'], function (Router $router) {
    // URI: /admin/setting
    $router->get('/setting', function () {
        return 'Setting Panel';
    });
});

// All of group attributes together!
$attributes = [
    'prefix' => '/admin',
    'domain' => 'shop.example.com',
    'middleware' => [AuthMiddleware::class],
];

$router->group($attributes, function (Router $router) {
    // URL: http://shop.example.com/admin/users
    // Domain: shop.example.com
    // Middleware: AuthMiddleware
    $router->get('/users', [UsersController::class, 'index']);
});

$router->dispatch();

The group attributes will be explained later in this documentation.

You can use Attributes enum, as well.

Middleware

PhpRouter supports middleware. You can use it for different purposes, such as authentication, authorization, throttles, and so forth. Middleware runs before and after controllers, and it can check and manipulate requests and responses.

Here you can see the request lifecycle considering some middleware:

[Request]  ↦ Router ↦ Middleware 1 ↦ ... ↦ Middleware N ↦ Controller
                                                              ↧
[Response] ↤ Router ↤ Middleware 1 ↤ ... ↤ Middleware N ↤ [Response]

To declare a middleware, you can use closures and classes just like controllers. To use the middleware, you must group the routes and mention the middleware in the group attributes. Caution! The middleware attribute in groups takes an array of middleware, not a single one.

use MiladRahimi\PhpRouter\Router;
use Psr\Http\Message\ServerRequestInterface;
use Laminas\Diactoros\Response\JsonResponse;

class AuthMiddleware
{
    public function handle(ServerRequestInterface $request, Closure $next)
    {
        if ($request->getHeader('Authorization')) {            
            // Call the next middleware/controller
            return $next($request);
        }

        return new JsonResponse(['error' => 'Unauthorized!'], 401);
    }
}

$router = Router::create();

// The middleware attribute takes an array of middleware, not a single one!
$router->group(['middleware' => [AuthMiddleware::class]], function(Router $router) {
    $router->get('/admin', function () {
        return 'Admin API';
    });
});

$router->dispatch();

As you can see, the middleware catches the request and the $next closure. The closure calls the next middleware or the controller if no middleware is left. The middleware must return a response, as well. A middleware can break the lifecycle and return a response itself, or it can call the $next closure to continue the lifecycle.

Domains and Subdomains

Your application may serve different services on different domains or subdomains. In this case, you can specify the domain or subdomain for your routes. See this example:

use MiladRahimi\PhpRouter\Router;

$router = Router::create();

// Domain
$router->group(['domain' => 'shop.com'], function(Router $router) {
    $router->get('/', function () {
        return 'This is shop.com';
    });
});

// Subdomain
$router->group(['domain' => 'admin.shop.com'], function(Router $router) {
    $router->get('/', function () {
        return 'This is admin.shop.com';
    });
});

// Subdomain with regex pattern
$router->group(['domain' => '(.*).example.com'], function(Router $router) {
    $router->get('/', function () {
        return 'This is a subdomain';
    });
});

$router->dispatch();

Route Names

You can assign names to your routes and use them in your codes instead of the hard-coded URLs. See this example:

use MiladRahimi\PhpRouter\Router;
use Laminas\Diactoros\Response\JsonResponse;
use MiladRahimi\PhpRouter\Url;

$router = Router::create();

$router->get('/about', [AboutController::class, 'show'], 'about');
$router->get('/post/{id}', [PostController::class, 'show'], 'post');
$router->get('/links', function (Url $url) {
    return new JsonResponse([
        'about' => $url->make('about'),             /* Result: /about  */
        'post1' => $url->make('post', ['id' => 1]), /* Result: /post/1 */
        'post2' => $url->make('post', ['id' => 2])  /* Result: /post/2 */
    ]);
});

$router->dispatch();

Current Route

You might need to get information about the current route in your controller or middleware. This example shows how to get this information.

$route->getName(), /* Result: "sample" */ 'path' => $route->getPath(), /* Result: "/{id}" */ 'method' => $route->getMethod(), /* Result: "GET" */ 'domain' => $route->getDomain(), /* Result: null */ 'parameters' => $route->getParameters(), /* Result: {"id": "1"} */ 'middleware' => $route->getMiddleware(), /* Result: [] */ 'controller' => $route->getController(), /* Result: {} */ ]); }, 'sample'); $router->dispatch(); ">
use MiladRahimi\PhpRouter\Router;
use Laminas\Diactoros\Response\JsonResponse;
use MiladRahimi\PhpRouter\Routing\Route;

$router = Router::create();

$router->get('/{id}', function (Route $route) {
    return new JsonResponse([
        'uri'    => $route->getUri(),            /* Result: "/1" */
        'name'   => $route->getName(),           /* Result: "sample" */
        'path'   => $route->getPath(),           /* Result: "/{id}" */
        'method' => $route->getMethod(),         /* Result: "GET" */
        'domain' => $route->getDomain(),         /* Result: null */
        'parameters' => $route->getParameters(), /* Result: {"id": "1"} */
        'middleware' => $route->getMiddleware(), /* Result: []  */
        'controller' => $route->getController(), /* Result: {}  */
    ]);
}, 'sample');

$router->dispatch();

IoC Container

PhpRouter uses PhpContainer to provide an IoC container for the package itself and your application's dependencies.

How does PhpRouter use the container?

PhpRouter binds route parameters, HTTP Request, Route (Current route), Url (URL generator), Container itself. The controller method or constructor can resolve these dependencies and catch them.

How can your app use the container?

Just look at the following example.

use MiladRahimi\PhpContainer\Container;
use MiladRahimi\PhpRouter\Router;

$router = Router::create();

$router->getContainer()->singleton(Database::class, MySQL::class);
$router->getContainer()->singleton(Config::class, JsonConfig::class);

// Resolve directly
$router->get('/', function (Database $database, Config $config) {
    // Use MySQL and JsonConfig...
});

// Resolve container
$router->get('/', function (Container $container) {
    $database = $container->get(Database::class);
    $config = $container->get(Config::class);
});

$router->dispatch();

Check PhpContainer for more information about this powerful IoC container.

Error Handling

Your application runs through the Router::dispatch() method. You should put it in a try block and catch exceptions. It throws your application and PhpRouter exceptions.

use MiladRahimi\PhpRouter\Router;
use MiladRahimi\PhpRouter\Exceptions\RouteNotFoundException;
use Laminas\Diactoros\Response\HtmlResponse;

$router = Router::create();

$router->get('/', function () {
    return 'Home.';
});

try {
    $router->dispatch();
} catch (RouteNotFoundException $e) {
    // It's 404!
    $router->getPublisher()->publish(new HtmlResponse('Not found.', 404));
} catch (Throwable $e) {
    // Log and report...
    $router->getPublisher()->publish(new HtmlResponse('Internal error.', 500));
}

PhpRouter throws the following exceptions:

  • RouteNotFoundException if PhpRouter cannot find any route that matches the user request.
  • InvalidCallableException if PhpRouter cannot invoke the controller or middleware.

The RouteNotFoundException should be considered 404 Not found error.

License

PhpRouter is initially created by Milad Rahimi and released under the MIT License.

Comments
  • Question Again

    Question Again

    I am looking at your examples and this one in question

    $router = Router::create();

    $router->get('/about', [AboutController::class, 'show'], 'about'); $router->get('/post/{id}', [PostController::class, 'show'], 'post'); $router->get('/links', function (Url $url) { return new JsonResponse([ 'about' => $url->make('about'), /* Result: /about / 'post1' => $url->make('post', ['id' => 1]), / Result: /post/1 / 'post2' => $url->make('post', ['id' => 2]) / Result: /post/2 */ ]); });

    $router->dispatch();

    when i follow the links /links i get the json information when i go /links/about or admin in my case it says page not found(my cyustom error handler)

    how would i get this to redirect to the page in querstiuon also where the [id =>1] can this take variables

    im sorry for the all the questions i really appreciate this script that you have done as its really amazing i would always recommend this

    tia

    opened by mbamber1986 12
  • Linking Middleware to an external file

    Linking Middleware to an external file

    Hello hope this can get answered i have recently found your script and i think its amazing my issue is

    when i place the middleware class within my routing files called web.php it runs the middleware script however if i do the following

    $router->get('/users', 'Users@index',\App\Middleware\AuthMiddleware::class);

    im getting this

    Fatal error: Uncaught MiladRahimi\PhpRouter\Exceptions\InvalidMiddlewareException: Invalid middleware for route: {"name":null,"uri":"/users","method":"GET","controller":"App\Models\Users@index","middleware":["App\Middleware\AuthMiddleware"],

    any help would be greatly appreciated

    opened by mbamber1986 12
  • Middleware: inject header in next

    Middleware: inject header in next

    How do I inject custom headers before calling $next?

    use MiladRahimi\PhpRouter\Router;
    use Psr\Http\Message\ServerRequestInterface;
    use Laminas\Diactoros\Response\JsonResponse;
    
    class AuthMiddleware
    {
        public function handle(ServerRequestInterface $request, Closure $next)
        {
            if ($request->getHeader('Authorization')) {            
    
    
    
    			// HOW: add header "X-Hello-World: true"
                return $next($request);
    
    
    
            }
    
            return new JsonResponse(['error' => 'Unauthorized!'], 401);
        }
    }
    
    $router = Router::create();
    
    // The middleware attribute takes an array of middleware, not a single one!
    $router->group(['middleware' => [AuthMiddleware::class]], function(Router $router) {
        $router->get('/admin', function () {
            return 'Admin API';
        });
    });
    
    $router->dispatch();
    
    opened by Luca-Castelnuovo 10
  • Question about obtaining list or urls from web file and the method type

    Question about obtaining list or urls from web file and the method type

    Hello again my friend i have a question more of an issue, still loving your router heres the case of use

    i am planning on building a roles, and rules system for my website and i want to base it on the url that it is currently at.

    so in this case i i can pull all the array values from $url, and the current value if i was to use ROUTE anyway i need to know if there is anyway i can simply pull just the path and the type of method it is

    so i can do soemthing like this in kmy admin panel

    foreach($url as $path) { echo "Path : $path['path'] . "Add rules" . "Method type " . $path['method'] }

    i litterly need to detect the url and the method post get etc

    and the rest i will do via middleware

    thanks in advance

    opened by mbamber1986 7
  • Middleware

    Middleware

    Hello am following your guide on middleware i am creating a class for middleware rather than storing it in the routes web file and im getting this error

    image

    here is my code

    image

    am i missing something thanks again

    opened by mbamber1986 5
  • Question

    Question

    Hi I was wondering is there a way in your code to stop it giving the scripts error message for example if i tell it i was int values only on the routing and i type string i get uncaught errors anyway i can formward this to a 404 page etc

    opened by mbamber1986 5
  • Get requestpath with variables

    Get requestpath with variables

    Would it be possible to have an $request->getUri() alternative that returns the base path.

    Example:

    1. Request to the route /example/{var} with /example/123
    2. $request->getUri() returns /example/123

    How would I get the original base (/example/{var})? Maybe $request->getBase()?

    opened by Luca-Castelnuovo 4
  • ServerRequest in constructor

    ServerRequest in constructor

    Is this possible?

    I get this error Fatal error: Uncaught ArgumentCountError: Too few arguments to function App\Controllers\Controller::__construct(), 0 passed ...

    class Controller
    {
        protected $request;
    
        /**
         * Provide access for child classes
         * 
         * @return void
         */
        public function __construct(ServerRequest $request)
        {
            // Load request
            // $this->request = $request;
        }
    }
    
    opened by Luca-Castelnuovo 4
  • Container: Reflection failed

    Container: Reflection failed

    When trying to get container it fails with an reflection error

    $this->router->getContainer()->singleton(\CQ\Config\Config::class, \CQ\Config\Config::class);
    
    $this->container->has(\CQ\Config\Config::class); // Returns true
    $this->container->get(\CQ\Config\Config::class); // Returns Reflection failed for CQ\Config\Config
    
    opened by Luca-Castelnuovo 3
  • OPTIONS request type for CORS

    OPTIONS request type for CORS

    Could you add $router->options('/', 'ExampleClass@options'); support?

    CORS sends an Pre-Flight request using the OPTIONS HTTP method. The only way to catch this currently is using the $router->any() method.

    But this removes the ability to create an RESTful endpoint. Because I can no longer create seperate routes for GET,POST,PUT,PATCH and DELETE.

    opened by Luca-Castelnuovo 3
  • Global Middleware

    Global Middleware

    Is this the best way to add global middleware?

    $router->group(['middleware' => SimpleMiddleware::class], function (Router $router) {
        // All routes go here
    });
    
    opened by Luca-Castelnuovo 3
  • Feature request: Override method

    Feature request: Override method

    Hello, in html forms, most browsers can't handle DELETE, PUT or PATCH as request method.

    Laravel has a feature that if there's a POST request with a hidden field named _method, it overrides the real method. this would require an additional check for $_POST["_method"]

    I'd really appreciate if a feature like this could be implemented, so this logic doesn't have to be implemented in each controller

    Thanks in advance, Moritz

    opened by Huber1 0
  • Group routes: Unable to access route where path is set as prefix root

    Group routes: Unable to access route where path is set as prefix root

    Tested with 5.1.4

    Not sure what is causing the issue?

    $router->group(['prefix' => '/admin'], function(Router $router) {
        $router->get('/', [PageController::class, 'main']); //  /admin throws MiladRahimi\PhpRouter\Exceptions\RouteNotFoundException
        $router->get('/dashboard', [PageController::class, 'dashboard']); //  /admin/dashboard works
    });
    
    opened by lewweiming 1
Releases(5.1.4)
Owner
Milad Rahimi
Software (Backend) Engineer @snapp-cab
Milad Rahimi
: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
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
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
PHP Router class - A simple Rails inspired PHP router class.

PHP Router class A simple Rails inspired PHP router class. Usage of different HTTP Methods REST / Resourceful routing Reversed routing using named rou

Danny van Kooten 565 Jan 8, 2023
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
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
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
Fast request router for PHP

FastRoute - Fast request router for PHP This library provides a fast implementation of a regular expression based router. Blog post explaining how the

Nikita Popov 4.7k Dec 23, 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
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
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
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
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
OpenAPI (Swagger) Specification Support for Sunrise Router (and not only)

OpenAPI (Swagger) Specification Support for Sunrise Router Important to understanding OpenAPI Specification Installation composer require 'sunrise/htt

Sunrise // PHP 3 Feb 12, 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
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
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