PHP library that provides a route matching and triggering procedure

5.31.0 2022-07-02 22:21 UTC

This package is auto-updated.

Last update: 2024-06-10 23:51:58 UTC


Release License PHP Version Style CI Code Size


QuidPHP/Routing is a PHP library that provides a route matching and triggering procedure. It is part of the QuidPHP package and can also be used standalone.


QuidPHP/Routing is available as an open-source software under the MIT license.


QuidPHP/Routing documentation is available at QuidPHP/Docs.


QuidPHP/Routing can be easily installed with Composer. It is available on Packagist.

$ composer require quidphp/routing

Once installed, the Quid\Routing namespace will be available within your PHP application.


QuidPHP/Routing requires the following:


QuidPHP/Routing has the following dependency:

  • quidphp/main - Quid\Main - PHP library that provides a set of base objects and collections

The dependency will be resolved by using the Composer installation process.


QuidPHP/Routing code is commented and all methods are explained (in French).


QuidPHP/Routing is built on the following conventions:

  • Coding: No curly braces are used in a IF statement if the condition can be resolved in only one statement.
  • Config: A special $config static property exists in all classes. This property gets recursively merged with the parents' property on initialization.
  • M-VC: A route object serves as both a View and a Controller. There should be one route class per route.
  • Segment: A segment within a route path represents a dynamic value. It is wrapped around brackets. A callable that accepts or rejects the value needs to be provided.
  • Templating: Once the route is triggered, the developer has complete control and can use any HTML rendering technology it desires. Or, simply use the Quid\Base\Html methods to generate the HTML and use traits for reusable page components.
  • Traits: Traits filenames start with an underscore (_).
  • Type: Files, function arguments and return types are strict typed.


QuidPHP/Routing contains 14 classes and traits. Here is an overview:

  • BreakException - Class for an exception which breaks the root matching loop
  • Exception - Class used for a route exception, the next available route will instead be triggered
  • Flash - Class for a collection containing flash-like data, manages route key
  • Nav - Class for storing route navigation-related data
  • Redirection - Class managing a URI redirection array
  • Request - Extended class with methods to route an HTTP request
  • RequestHistory - Extended class for a collection containing a history of requests
  • Route - Abstract class for a route that acts as both a View and a Controller
  • RouteRequest - Class that analyzes if a request matches a route
  • RouteSegmentRequest - Class that analyzes if a request matches a route with segment (non-static value)
  • Routes - Class for a collection of many untriggered routes
  • Session - Extended class that adds session support for routes
  • _attrRoute - Trait that provides methods to work with routes in the attributes property
  • _service - Trait that provides methods to link a service to a route


QuidPHP/Routing contains 7 test classes:

  • BreakException - Class for testing Quid\Routing\BreakException
  • Exception - Class for testing Quid\Routing\Exception
  • Nav - Class for testing Quid\Routing\Nav
  • Redirection - Class for testing Quid\Routing\Redirection
  • Request - Class for testing Quid\Routing\Request
  • RequestHistory - Class for testing Quid\Routing\RequestHistory
  • Session - Class for testing Quid\Routing\Session

QuidPHP/Routing testsuite can be run by creating a new QuidPHP/Assert project.