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

ArchivedLibrary[API Development](/categories/api)

ft/just-routes
==============

A library simply for routing requests. Simple. Light. Fast

1.3.1(3y ago)010MITPHP

Since Dec 16Pushed 3y ago1 watchersCompare

[ Source](https://github.com/soulshined/ft-just-routes)[ Packagist](https://packagist.org/packages/ft/just-routes)[ RSS](/packages/ft-just-routes/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (6)Used By (0)

Just Routes
===========

[](#just-routes)

A extremely lightweight, fast and focused PHP library strictly for routing requests. No hassle, no framework required.

Just attributes, plain old PHP, and just routes

Usage
-----

[](#usage)

1. `composer require ft/just-routes`
2. [Create controller\[s\]](#create-controllers)
3. [Register controller\[s\]](#create-controllers)
4. [Add optional methods](#customize)
5. [Dispatch Request](#the-end)

### Create Controllers

[](#create-controllers)

```
final class MyController {

}
```

1. Annotate your controller with request mapping

```
#[RequestMapping(value: "/foobar")]
final class MyController {

}
```

2. Add routes as methods to controller

```
#[RequestMapping(value: "/foobar")]
final class MyController {

    #[GetMapping]
    function voidMethod() { // maps to GET /foobar
    }

    #[GetMapping(value: "/bazz")]
    function get_bazz() { // maps to GET /foobar/bazz
        echo "bazz";
    }

}
```

### Register Controllers

[](#register-controllers)

```
RouteFactory::registerController(MyController::class);
```

### Customize

[](#customize)

You can customize a few control flow patterns:

1. Exceptions
2. Not Found Paths

#### Exceptions

[](#exceptions)

You can catch exceptions at the controller layer or globally via RouteFactory

scoped exception handling via controller annotation

```
#[RequestMapping(value: "/foobar")]
final class MyController {

    #[GetMapping]
    function voidMethod() { // maps to GET /foobar
        throw new IllegalArgumentException("Illegal");
    }

    #[GetMapping(value: "/bazz")]
    function get_bazz() { // maps to GET /foobar/bazz
        throw new IllegalArgumentException("Illegal");
    }

    #[ExceptionHandler(IllegalArgumentException::class)]
    function handle_illegal_arg_exc(IllegalArgumentException $exc, string $path) {
        //swallowed IllegalArgumentException only from this controller's routes
    }

}
```

globally catching exceptions

```
RouteFactory::registerController(MyController::class);
RouteFactory::onException(IllegalArgumentException::class, function (string $path) {
    echo "Caught globally";
});
```

#### Not Found

[](#not-found)

globally handle

```
RouteFactory::registerController(MyController::class);
RouteFactory::onNotFound(function ($path) {
    echo "$path not found";
});
```

### The End

[](#the-end)

That's it to get routing configured. Now simply dispatch the request

```
RouteFactory::registerController(MyController::class);
RouteFactory::dispatch();
```

### Miscellaneous

[](#miscellaneous)

#### Semantic Attributes

[](#semantic-attributes)

- \#\[GetMapping\]
- \#\[PutMapping\]
- \#\[PostMapping\]
- \#\[DeleteMapping\]

#### Other Attributes

[](#other-attributes)

- \#\[RequestMapping\]
- \#\[ExceptionHandler\]
- \#\[RequestParam\] - Inject a request parameter directly as a method parameter

    ```
    #[RequestMapping(value: "/foobar")]
    final class MyController {

        #[GetMapping("/id/{id}")]
        public function get_foo(int $id, #[RequestParam] string $internal, #[RequestParam] array $foos) {
            // Example req:
            // GET /foobar/id/1?internal=true&foos[]=1&foos[]=2&foos[]=3
        }
    }
    ```
- \#\[RequestHeader\] - Inject a header directly as a method parameter

    ```
    #[RequestMapping(value: "/foobar")]
    final class MyController {

        #[GetMapping("/id/{id}")]
        public function get_foo(int $id, #[RequestHeader] string $referer) {

        }
    }
    ```

#### Route Syntax

[](#route-syntax)

Routes are separated by `/`, must start with `/` and must not duplicate for HTTP method types

Routes may contain path variables. A path variable is encapsulated by `{}` curly braces.

Routes with path variables must have parameters in the route method signature

For example:

```
#[RequestMapping(value: "/foobar")]
final class MyController {

    #[GetMapping(value: "/name/{name}/age/{age}")]
    function get_for_name_age(string $name, int $age) {
        // example req
        // GET /foobar/name/John/age/18
    }

}
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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.

###  Release Activity

Cadence

Every ~15 days

Total

5

Last Release

1185d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1a9ec50a967899163d0d22508c6e3b72b930f51e2d36213ac0bc782910ad46a2?d=identicon)[davidfreer](/maintainers/davidfreer)

---

Top Contributors

[![soulshined](https://avatars.githubusercontent.com/u/11242654?v=4)](https://github.com/soulshined "soulshined (11 commits)")

---

Tags

phpapiroutingcontroller

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ft-just-routes/health.svg)

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

###  Alternatives

[jstolpe/instagram-graph-api-php-sdk

Instagram Graph API PHP SDK

13998.4k2](/packages/jstolpe-instagram-graph-api-php-sdk)

PHPackages © 2026

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