PHPackages                             sigmaphp/sigmaphp-router - 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. sigmaphp/sigmaphp-router

ActiveLibrary[Framework](/categories/framework)

sigmaphp/sigmaphp-router
========================

PHP Router

0.1.16(1w ago)029↓100%1MITPHPCI passing

Since Sep 30Pushed 3d ago1 watchersCompare

[ Source](https://github.com/SigmaPHP/SigmaPHP-Router)[ Packagist](https://packagist.org/packages/sigmaphp/sigmaphp-router)[ RSS](/packages/sigmaphp-sigmaphp-router/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (1)Versions (18)Used By (1)

SigmaPHP-Router
===============

[](#sigmaphp-router)

A fast and simple router for PHP , you can use for your projects to provide user friendly URLs , you can build your app in a simple functional style , to write RESTfull API services or to build a fully functional MVC.

Features
--------

[](#features)

- Support placeholder parameters e.g `{name}`
- Use optional parameters with the route
- Auto parsing for the GET query parameters
- Support all HTTP methods GET, POST, PUT ... etc
- Routes can accept multiple HTTP methods
- Support `any` method , so the route can accept all HTTP methods
- Routes Validation using regex expressions
- Actions can be implemented as regular functions or controller's method
- Support for Single Action Controllers
- Middlewares , that can be run before your route
- Route Groups which support middlewares , controllers and prefix
- URL generation using the route name
- Default page not found (404) handler and you can define custom handler
- Custom action runners , for advanced customization
- HTTP method override
- Static assets routing

Installation
------------

[](#installation)

```
composer require agashe/sigmaphp-router

```

Configurations
--------------

[](#configurations)

Depending on your server environment, you’ll need to use one of the provided configuration files. These files include example setups for several popular web servers, including Apache, Nginx, Lighttpd, IIS, and Caddy.

To use the router with any of these servers , just copy the corresponding config file from the `configs` folder to the root folder of your project.

For example , in case you are using Apache server , copy the `apache_htaccess` file and rename it to the proper name `.htaccess`

Please note : all of the provided config files , assume that the main entry point to your application is `index.php` located in the root path of your project's directory. If you have different setup for your project , check please the config and make sure it's pointing to the correct path.

So if the `index.php` is located under the `public` folder. Then in the `.htaccess` file , change `index.php` to `public/index.php` , and the same goes for other servers.

Documentation
-------------

[](#documentation)

#### Table of Contents

[](#table-of-contents)

- [Basic Setup](#basic-setup)
- [Base Path](#base-path)
- [HTTP Methods](#http-methods)
- [Parameters](#parameters)
- [Validation](#validation)
- [Actions](#actions)
- [Middlewares](#middlewares)
- [Route Groups](#route-groups)
- [Page not found handling](#page-not-found-handling)
- [URL Generation](#url-generation)
- [Action Runners](#action-runners)
- [HTTP Method Override](#http-method-override)
- [Static Assets Routing](#static-assets-routing)
- [Examples](#examples)

### Basic Setup

[](#basic-setup)

In order to start using SigmaPHP-Router in your app , in the main entry point of your app (say for example `index.php` ), you first need define the routes array , then pass that array to the constructor and finally call the the `run()` method.

```
