PHPackages                             unocha/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. [Framework](/categories/framework)
4. /
5. unocha/klein

ActiveLibrary[Framework](/categories/framework)

unocha/klein
============

A lightning fast router for PHP

v4.0.0(2mo ago)219.5k↓19.3%MITPHPPHP &gt;=8.5

Since Feb 22Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/UN-OCHA/rwint-klein.php)[ Packagist](https://packagist.org/packages/unocha/klein)[ Docs](https://github.com/UN-OCHA/rwint-klein.php)[ RSS](/packages/unocha-klein/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (13)Used By (0)

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

[](#kleinphp)

**Note:** This `rwint-klein.php` is an updated version of  to work with PHP 8.5+ and therefore is not compatible with older versions of PHP.

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

- 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; [2500+ requests/second](https://gist.github.com/878833)

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

[](#getting-started)

1. PHP 8.5.x 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

```
