PHPackages                             elcapitansponge/phlounder - 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. elcapitansponge/phlounder

AbandonedArchivedLibrary

elcapitansponge/phlounder
=========================

Minimalistc semi-opinionated PHP router

v0.1.1(2y ago)12[2 issues](https://github.com/ElCapitanSponge/phlounder/issues)MITPHPPHP &gt;=8.3

Since Mar 17Pushed 2y ago1 watchersCompare

[ Source](https://github.com/ElCapitanSponge/phlounder)[ Packagist](https://packagist.org/packages/elcapitansponge/phlounder)[ Docs](https://github.com/ElCapitanSponge/phlounder)[ RSS](/packages/elcapitansponge-phlounder/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

PHlounder
=========

[](#phlounder)

Minimalistic opinionated PHP Routing engine

[![PHP](https://camo.githubusercontent.com/b5f049288f64c6d87a1b492b5b8ccb9305c31044edd0d7bb4a17a25936d1a75d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f504850253230382e332b2d707572706c652e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d706870)](https://www.php.net)

⇁ About
-------

[](#-about)

A minimalistic routing engine for PHP allowing route parameters for GET, POST, PUT, DELETE and OPTIONS. The only thing missing is **your code**.

⇁ Installation
--------------

[](#-installation)

### Composer

[](#composer)

```
composer require elcapitansponge/phlounder
```

### Git

[](#git)

**NOTE** As this is still in development cloning the repo is the way to go.

```
git clone https://github.com/ElCapitanSponge/phlounder.git
```

or

```
git clone git@github.com:ElCapitanSponge/phlounder.git
```

⇁ Getting Started
-----------------

[](#-getting-started)

### Calling the library

[](#calling-the-library)

Include the library in your script

#### Composer

[](#composer-1)

```
require __DIR__ . "/vendor/autoload.php"
```

#### Git Clone

[](#git-clone)

Alternitively you can load the files using the following snippet

```
$phlounder_path = "./phlounder/";

foreach (glob("{$phlounder_path}src/**/*.php") as $filename) {
    include $filename;
}
foreach (glob("{$phlounder_path}src/*.php") as $filename) {
    include $filename;
}
```

### Using the library

[](#using-the-library)

An example implementation of phlounder is as follows

```
use phlounder\Router;
use phlounder\lib\ResponseCodes;
use phlounder\router\Request;
use phlounder\router\Response;

$router = new Router();

$router->get("/", function (Request $req, Response $res) {
    $res->to_json(ResponseCodes::OK, "Hello World!");
});

$router->get("/user/{id}", function (Request $req, Response $res) {
    $data = new \stdClass();
    $data->params = $req->get_params();
    $res->to_json(ResponseCodes::OK, $data);
});

$router->post("/user", function (Request $req, Response $res) {
    $res->to_json(ResponseCodes::CREATED);
});

$router->put("/user/{id}", function (Request $req, Response $res) {
    $res->to_json(ResponseCodes::OK);
});

$router->delete("/user/{id}", function (Request $req, Response $res) {
    $res->to_json(ResponseCodes::OK);
});

$router->none_found();
```

### Route Handling

[](#route-handling)

The routing due to the nature of implementation follows the order of precidence. In otherwords, a top to bottom approach when processing.

This is apparent with the following snippet:

```
$router->get("/user/{id}", function (Request $req, Response $res) {
    $data = new \stdClass();
    $data->params = $req->get_params();
    $res->to_json(ResponseCodes::OK, $data);
});

$router->get("/user/foo", function (Request $req, Response $res) {
    $res->to_json(ResponseCodes::OK, "Bar!");
});
```

In the above snippet if you hit `/user/foo`You don't recieve:

```
{
    "code": 200,
    "data": "Bar!"
}
```

Instead you recieve:

```
{
    "code": 200,
    "data": {
        "params": {
            "id": "foo"
        }
    }
}
```

To resolve this issue we have to place the `/user/foo` route before `/user/{id}`

```
$router->get("/user/foo", function (Request $req, Response $res) {
    $res->to_json(ResponseCodes::OK, "Bar!");
});

$router->get("/user/{id}", function (Request $req, Response $res) {
    $data = new \stdClass();
    $data->params = $req->get_params();
    $res->to_json(ResponseCodes::OK, $data);
});
```

### Route paramater types

[](#route-paramater-types)

There is type handling for `string` or `int` in the route params if desired.

Taking the following:

```
$router->get("/users/{id:i}", function (Request $req, Response $res) {
    $data = new \stdClass();
    $data->params = $req->get_params();
    $res->to_json(ResponseCodes::OK, $data);
});

$router->get("/course/{code:s}", function (Request $req, Response $res) {
    $data = new \stdClass();
    $data->params = $req->get_params();
    $res->to_json(ResponseCodes::OK, $data);
});

$router->get("/category/{id}", function (Request $req, Response $res) {
    $data = new \stdClass();
    $data->params = $req->get_params();
    $res->to_json(ResponseCodes::OK, $data);
});
```

- `/users/{id:i}`: The `id` param is specified to be an `int`
- `/course/{code:s}`: The `code` param is specified to be a `string`
- `/category/{id}`: The `id` param can be either a `string` or an `int`

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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 ~2 days

Total

2

Last Release

783d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c1dd9ac580cf270d6b8c1579f4f11ab220df2a74854afec654a1a1ec8f873df5?d=identicon)[ElCapitanSponge](/maintainers/ElCapitanSponge)

---

Top Contributors

[![ElCapitanSponge](https://avatars.githubusercontent.com/u/5303562?v=4)](https://github.com/ElCapitanSponge "ElCapitanSponge (37 commits)")

---

Tags

routing

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/elcapitansponge-phlounder/health.svg)

```
[![Health](https://phpackages.com/badges/elcapitansponge-phlounder/health.svg)](https://phpackages.com/packages/elcapitansponge-phlounder)
```

###  Alternatives

[symfony/routing

Maps an HTTP request to a set of configuration variables

7.6k789.4M1.8k](/packages/symfony-routing)[nikic/fast-route

Fast request router for PHP

5.3k92.4M668](/packages/nikic-fast-route)[friendsofsymfony/jsrouting-bundle

A pretty nice way to expose your Symfony routing to client applications.

1.5k53.6M229](/packages/friendsofsymfony-jsrouting-bundle)[symfony-cmf/routing

Extends the Symfony routing component for dynamic routes and chaining several routers

29151.1M64](/packages/symfony-cmf-routing)[nette/application

🏆 Nette Application: a full-stack component-based MVC kernel for PHP that helps you write powerful and modern web applications. Write less, have cleaner code and your work will bring you joy.

44615.4M983](/packages/nette-application)[laminas/laminas-router

Flexible routing system for HTTP and console applications

3520.6M64](/packages/laminas-laminas-router)

PHPackages © 2026

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