PHPackages                             szenis/routing - 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. [API Development](/categories/api)
4. /
5. szenis/routing

ActiveLibrary[API Development](/categories/api)

szenis/routing
==============

A small and simple PHP router

v2.0.3(8y ago)162.4k32MITPHPPHP &gt;=5.3.0

Since Jan 25Pushed 8y ago5 watchersCompare

[ Source](https://github.com/stein189/Simple-PHP-Router)[ Packagist](https://packagist.org/packages/szenis/routing)[ RSS](/packages/szenis-routing/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (6)Dependencies (1)Versions (23)Used By (2)

Simple PHP Router
=================

[](#simple-php-router)

[![Latest Stable Version](https://camo.githubusercontent.com/30369e46748701a5cbc3189cb0aa6911bf32e115d199c0934766ae6e3dc70ae7/68747470733a2f2f706f7365722e707567782e6f72672f737a656e69732f726f7574696e672f762f737461626c65)](https://packagist.org/packages/szenis/routing)[![Total Downloads](https://camo.githubusercontent.com/eb4172f89c499331cdbe684b188793a59cd6d5dd4d7daebd69306664fa248617/68747470733a2f2f706f7365722e707567782e6f72672f737a656e69732f726f7574696e672f646f776e6c6f616473)](https://packagist.org/packages/szenis/routing)[![Build Status](https://camo.githubusercontent.com/2bd8f869e2639f63659bab3c66c8376095137325cb4170731ebfd48bc3b20f17/68747470733a2f2f7472617669732d63692e6f72672f737465696e3138392f53696d706c652d5048502d526f757465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/stein189/Simple-PHP-Router)

**Updating from version 0.x or 1.x will break your code! read the documentation before upgrading!**

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

[](#getting-started)

**Step 1 - .htaccess file**create an .htaccess file in the root of your project and fill it with the code below:

```

        Options -MultiViews

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

```

**Step 2 - require szenis/routing**
In your terminal execute: `composer require szenis/routing`

**Step 3 - create index.php**
Create the file index.php in the root of your project

**Step 4 - require autoload.php and use the Router**

The following snippet shows how the router can be used.

```
