This library provides a fast implementation of a regular expression-based router. Firstly, while writing a PHP extension is obviously a lot of fun, it is unlikely to be particularly beneficial in terms of performance unless the code involves computations in tight loops. Porting “normal” components like routers to C is usually a big waste of time. You can get much better results by doing a few small improvements on the algorithmic side. For the same reason I’m not a big fan of things like Phalcon, i.e. PHP frameworks written as a C extension. You can get good performance by using an appropriate application design (that is not massively overengineered) and still retain the flexibility of keeping everything in PHP. 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.

Features

  • The routes are defined by calling the FastRoute\simpleDispatcher() function
  • Custom patterns for route placeholders cannot use capturing groups
  • Shortcut methods for common request methods
  • You can specify routes inside of a group
  • Nested groups are also supported
  • The route parser can be overwritten individually (to make use of some different pattern syntax)

Project Samples

Project Activity

See All Activity >

Categories

Router

Follow FastRoute

FastRoute Web Site

Other Useful Business Software
Train ML Models With SQL You Already Know Icon
Train ML Models With SQL You Already Know

BigQuery automates data prep, analysis, and predictions with built-in AI assistance.

Build and deploy ML models using familiar SQL. Automate data prep with built-in Gemini. Query 1 TB and store 10 GB free monthly.
Try Free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of FastRoute!

Additional Project Details

Programming Language

PHP

Related Categories

PHP Router Firmware

Registered

2021-12-03