PHPackages                             hoben/simple-routes - 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. hoben/simple-routes

ActiveLibrary[Framework](/categories/framework)

hoben/simple-routes
===================

Simple routing package for PHP.

07PHP

Since Apr 19Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Hoben/Simple-Routes)[ Packagist](https://packagist.org/packages/hoben/simple-routes)[ RSS](/packages/hoben-simple-routes/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Simple PHP Routes
=================

[](#simple-php-routes)

[![Author](https://camo.githubusercontent.com/b909ed76dd5b6b3ae5388a6ad2253545e418cd901f497a52f1b1c7ae4436ea81/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d686f62656e2d626c75652e737667)](https://github.com/Hoben)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

Simple and easy-to-use router built for beginners and light-weight projects.

This package is compliant with \[PSR-2\]

Install
-------

[](#install)

Via Composer

```
$ composer require hoben/simple-routes
```

Requirements
------------

[](#requirements)

- PHP ^5.5.9 | &gt;=7.0.8
- Symfony/yaml: ^3.4

Features
--------

[](#features)

- Create routes defined in yaml files
- You can also add routes in code with the function add of the class Router.php
- You can filter routes by methods ( GET, POST, PUT ,DELETE,...)

### Adding routes with yaml file (routes.yaml)

[](#adding-routes-with-yaml-file-routesyaml)

```
"Dashboard":
  url: /
  controller: indexController
  action: index
  method: GET

"Test Page":
  url: /
  controller: indexController
  action: showTest
  method: POST

"default":
  controller: defaultController
  action: show404
```

```
$router = new Router();
$router->setBasePath('my-app/'); // Example: for www.localhost/my-app
$router->setControllersPath('src/controllers/'); // Example: for controllers in www.localhost/my-app/src/controllers
$router->setConfigPath('yaml-file-path/routes.yaml') // The yaml file path
$router->match();
```

### Adding routes with PHP code

[](#adding-routes-with-php-code)

```
use Hoben\SimpleRoutes\Router;

$router = new Router();

$route->add('/products', 'ProductController', 'getProducts', 'GET');
$route->add('/product', 'ProductController', 'getProduct', 'GET');
$route->add('/product', 'ProductController', 'addProduct', 'POST');
$route->add('/product', 'ProductController', 'updateProduct', 'PUT');

$router->setBasePath('my-app/'); // Example: for www.localhost/my-app
$router->setControllersPath('src/controllers/'); // Example: for controllers in www.localhost/my-app/src/controllers
$router->match();
```

### Bonus: How to redirect all urls to index.php

[](#bonus-how-to-redirect-all-urls-to-indexphp)

Create a simple .htaccess file on your root directory if you're using Apache with mod\_rewrite enabled.

```
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)$ index.php [NC,L]
```

If you're using nginx, setup your server section as following:

```
server {
	listen 80;
	server_name mywebsite.dev;
	root /var/www/mywebsite/public;

	index index.php;

	location / {
		try_files $uri $uri/ /index.php?$query_string;
	}

	location ~ \.php$ {
		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

		# With php5-fpm:
		fastcgi_pass unix:/var/run/php5-fpm.sock;
		fastcgi_index index.php;
		include fastcgi.conf;
		fastcgi_intercept_errors on;
	}
}
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/hoben/simple-routes/master/LICENSE.md) for more information.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/02f0d3baf77c3894aa54dfe39d348ddc2ff4f448dc513acc9be10ead4a477eb4?d=identicon)[Hoben](/maintainers/Hoben)

---

Top Contributors

[![Hoben](https://avatars.githubusercontent.com/u/4363858?v=4)](https://github.com/Hoben "Hoben (29 commits)")

---

Tags

beginner-friendlyphprouting

### Embed Badge

![Health badge](/badges/hoben-simple-routes/health.svg)

```
[![Health](https://phpackages.com/badges/hoben-simple-routes/health.svg)](https://phpackages.com/packages/hoben-simple-routes)
```

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M190](/packages/laravel-telescope)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M529](/packages/laravel-passport)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M255](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M591](/packages/laravel-prompts)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
