PHPackages                             matecat/klein - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. matecat/klein

ActiveLibrary[HTTP &amp; Networking](/categories/http)

matecat/klein
=============

A lightning fast router for PHP

v3.2.2(2mo ago)01.5k↓27.3%MITPHPPHP &gt;=8.3

Since Feb 22Pushed 2mo agoCompare

[ Source](https://github.com/matecat/klein.php)[ Packagist](https://packagist.org/packages/matecat/klein)[ Docs](https://github.com/matecat/klein.php)[ RSS](/packages/matecat-klein/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (18)Used By (0)

Klein.php
=========

[](#kleinphp)

[![Build Status](https://camo.githubusercontent.com/462663a4e4fe7766de21d767b7cfa19fb056abcd9de6e3d36d0a7f7ff8f657ef/68747470733a2f2f6170702e7472617669732d63692e636f6d2f6d6174656361742f6b6c65696e2e7068702e7376673f746f6b656e3d7142617a786b4877503138683345576e486a6a46266272616e63683d6d6173746572)](https://app.travis-ci.com/matecat/klein.php)![license](https://camo.githubusercontent.com/8dae55308fb293f486d5167ecc7baacb5b09a5c35f176d3a0110b3cdd122a2e9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6174656361742f6b6c65696e2e7068702e737667)![Packagist](https://camo.githubusercontent.com/606ddeab9af135846aa75d5b651e73323f657b8ae5fc71c89e5b217794ff7b8c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6174656361742f6b6c65696e2e737667)[![Quality Gate Status](https://camo.githubusercontent.com/b5ff9b85eb77bd81850710cfbab2468f0b936804ade130704819638b491284e8/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6d6174656361745f6b6c65696e2e706870266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/summary/new_code?id=matecat_klein.php)[![Coverage](https://camo.githubusercontent.com/2fe70810cfad575fa3ea076832b6730a1e4168c0c373dffe651d9249c1e3a563/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6d6174656361745f6b6c65696e2e706870266d65747269633d636f766572616765)](https://sonarcloud.io/summary/new_code?id=matecat_klein.php)[![Reliability Rating](https://camo.githubusercontent.com/e2701a5d4a1101db81800fe8c3e85c682a746038bef488838f22d29cfc7d82e8/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6d6174656361745f6b6c65696e2e706870266d65747269633d72656c696162696c6974795f726174696e67)](https://sonarcloud.io/summary/new_code?id=matecat_klein.php)[![Maintainability Rating](https://camo.githubusercontent.com/adf8401770d203d71a832756741edc96b4cb306a88088a032a89c1e867bac2c8/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d6d6174656361745f6b6c65696e2e706870266d65747269633d7371616c655f726174696e67)](https://sonarcloud.io/summary/new_code?id=matecat_klein.php)

**klein.php** is a fast &amp; flexible router for PHP

- Flexible regular expression routing (inspired by [Sinatra](http://www.sinatrarb.com/))
- A set of [boilerplate methods](#api) for rapidly building web apps
- Almost no overhead =&gt; [Benchmarks](BENCHMARKS.md)
    - Benchmark framework:

Overview
--------

[](#overview)

This repository is a fork of the original project, created to restore active maintenance and modernize the codebase. We use this library in production and have committed to keeping it up to date and compatible with current PHP versions. The primary goal of this fork is to enable and support PHP 8.3 while preserving the original project's spirit and API where possible.

Getting started
---------------

[](#getting-started)

1. PHP &gt;= 8.3 is required
2. Install Klein using [Composer](#composer-installation) (recommended) or manually
3. Setup [URL rewriting](https://gist.github.com/874000) so that all requests are handled by **index.php**
4. (Optional) Throw in some [APC](http://pecl.php.net/package/APC) for good measure

Composer Installation
---------------------

[](#composer-installation)

1. Get [Composer](http://getcomposer.org/)
2. Require Klein with `php composer.phar require klein/klein`
3. Add the following to your application's main PHP file: `require 'vendor/autoload.php';`

Example
-------

[](#example)

*Hello World* - Obligatory hello world example

```
