PHPackages                             lesichkovm/php-autoroute - 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. lesichkovm/php-autoroute

ActiveLibrary

lesichkovm/php-autoroute
========================

Automatically maps a provided route to a controller and method

v2.0.0(8y ago)115proprietaryPHP

Since Apr 1Pushed 7y ago1 watchersCompare

[ Source](https://github.com/lesichkovm/php-autoroute)[ Packagist](https://packagist.org/packages/lesichkovm/php-autoroute)[ Docs](http://github.com/lesichkovm/php-autoroute)[ RSS](/packages/lesichkovm-php-autoroute/feed)WikiDiscussions master Synced today

READMEChangelog (2)DependenciesVersions (3)Used By (0)

PHP Autoroute
=============

[](#php-autoroute)

The "set-and-forget" smart router script.

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

[](#installation)

### A. Use composer (preferred)

[](#a-use-composer-preferred)

```
composer require lesichkovm/php-autoroute
```

### B. Manually via composer

[](#b-manually-via-composer)

Add the following to your composer file:

```
   "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/lesichkovm/php-autoroute.git"
        }
    ],
    "require": {
        "lesichkovm/php-autoroute": "dev-master"
    },
```

How does it work?
-----------------

[](#how-does-it-work)

Just from the route (URI) it will find and execute the appropriate controller and method. Pass the current route and autoroute will call the associated controller and method.

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

[](#requirements)

Your controller classes must be either included (i.e. using require\_once), or you must have an autoload function registered (recommended).

See  for how to register and autoload classes.

Example routes
--------------

[](#example-routes)

Route: /admin/user-management/view-users

Executes: Admin\\UserManagementController@viewUsers

Route: user/admin/test/home

Executes: User\\Admin\\TestController@home

Example routes using request method
-----------------------------------

[](#example-routes-using-request-method)

Route: /admin/user-management/view-users

Executes: Admin\\UserManagementController@getViewUsers

Route: user/admin/test/home

Executes: User\\Admin\\TestController@getHome

How to use
----------

[](#how-to-use)

### Simple One Line Example

[](#simple-one-line-example)

```
autoroute(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
```

### Advanced Options with Exception Catching

[](#advanced-options-with-exception-catching)

```
// 1. Get the current route
$route = isset($_REQUEST['route']) ? $_REQUEST['route'] : '';

// 2. Autoroute
try {
    autoroute($route, [
        'default_method' => 'index',
        'default_controller' => 'Guest',
        'default_namespace' => 'App\\Controllers',
        'use_request_method' => true,
    ]);
} catch (ReflectionException $re) {
    // Page not found
    die('Not found:' . $re->controller . '@' . $re->method);
} catch (Exception $e) {
    // Other non routing related exception
    // Deal with exception (i.e. send yourself a mail)
    die('Exception occurred');
}
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2961d ago

Major Versions

1.0.0 → v2.0.02018-04-01

### Community

Maintainers

![](https://www.gravatar.com/avatar/2d5e7549502cd22df16f7dddbc83eb579b3995874be024d64f7f0f7dab2e1e8d?d=identicon)[lesichkovm](/maintainers/lesichkovm)

---

Top Contributors

[![lesichkovm](https://avatars.githubusercontent.com/u/7744963?v=4)](https://github.com/lesichkovm "lesichkovm (32 commits)")

---

Tags

phprouteautolesichkov

### Embed Badge

![Health badge](/badges/lesichkovm-php-autoroute/health.svg)

```
[![Health](https://phpackages.com/badges/lesichkovm-php-autoroute/health.svg)](https://phpackages.com/packages/lesichkovm-php-autoroute)
```

###  Alternatives

[lesichkovm/laravel-advanced-route

Advanced route class for Laravel - restoring implicit controllers to the framework.

70140.7k1](/packages/lesichkovm-laravel-advanced-route)[eftec/routeone

Router service class for PHP

291.4k2](/packages/eftec-routeone)

PHPackages © 2026

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