PHPackages                             strukt/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. [HTTP &amp; Networking](/categories/http)
4. /
5. strukt/router

ActiveLibrary[HTTP &amp; Networking](/categories/http)

strukt/router
=============

Strukt Router

v1.1.5-alpha(1y ago)29461MITPHPPHP ^8.1

Since Jun 20Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/struktapp/strukt-router)[ Packagist](https://packagist.org/packages/strukt/router)[ RSS](/packages/strukt-router/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (5)Versions (12)Used By (1)

Strukt Router
=============

[](#strukt-router)

[![Build Status](https://camo.githubusercontent.com/86ffce223e099a99202e5d99cfbf9d5e1dcfdb09ab195bffdc48b32e03373e00/68747470733a2f2f7472617669732d63692e6f72672f706974736f6c752f737472756b742d726f757465722e7376673f6272616e63683d6d6173746572)](https://packagist.org/packages/strukt/router)[![Latest Stable Version](https://camo.githubusercontent.com/e34eadbaf1d4f8290a5843ed1b92572db9f92acd6f7a7eb878b83c75c22e0641/68747470733a2f2f706f7365722e707567782e6f72672f737472756b742f726f757465722f762f737461626c65)](https://packagist.org/packages/strukt/router)[![Total Downloads](https://camo.githubusercontent.com/57dc93d232fa126087e4be6773ccbde2e484f7d4ccdf15126e9dbb69965ed93f/68747470733a2f2f706f7365722e707567782e6f72672f737472756b742f726f757465722f646f776e6c6f616473)](https://packagist.org/packages/strukt/router)[![Latest Unstable Version](https://camo.githubusercontent.com/e8fe1435903dbd2ae3eac375650d38d0d2ea3f382db59bedd126af164232b0dc/68747470733a2f2f706f7365722e707567782e6f72672f737472756b742f726f757465722f762f756e737461626c65)](https://packagist.org/packages/strukt/router)[![License](https://camo.githubusercontent.com/9e1a2c6aa207e5a3f41650b8c40ffc796ae1429d958ad3754b3e7f92b7fc58fe/68747470733a2f2f706f7365722e707567782e6f72672f737472756b742f726f757465722f6c6963656e7365)](https://packagist.org/packages/strukt/router)

Getting Started
---------------

[](#getting-started)

### Quick Start

[](#quick-start)

Create `composer.json` script with contents below then run `composer update`

```
{
    "require":{

        "strukt/router":"v1.1.5-alpha"
    },
    "minimum-stability":"dev"
}
```

Your `index.php` file.

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

use Strukt\Http\Request;
// use Strukt\Http\Response\Plain as Response;

$app = new Strukt\Router\QuickStart();

$app->get("/", function(Request $request){

    // return new Response("Hello World!");
    return "Hello World!";
});

exit($app->run());
```

Advanced Router (The Nitty Gritty)
----------------------------------

[](#advanced-router-the-nitty-gritty)

### Permissions

[](#permissions)

```
$app->inject("permissions", function(){

    return array(

        // "show_secrets"
    );
});

$app->providers(array(

    //App\Provider\ExampleProvider::class
));

$app->middlewares(array(

    Strukt\Router\Middleware\Session::class,
    Strukt\Router\Middleware\Authentication::class,
    Strukt\Router\Middleware\Authorization::class,
));

$app->get("/user/secrets", function(){

    return "Shh!";

},"show_secrets");

exit($app->run());
```

### Authentication

[](#authentication)

```
$app->inject("permissions", function(){

    return [];
});

$app->inject("session", function(){

    return new Strukt\Http\Session\Native;
});

$app->inject("verify", function(Strukt\Http\Session\Native $session){

    $user = new Strukt\User();
    $user->setUsername($session->get("username"));

    return $user;
});

$app->providers(array(

    //App\Provider\ExampleProvider::class
));

$app->middlewares(array(

    Strukt\Router\Middleware\Session::class,
    Strukt\Router\Middleware\Authentication::class,
    Strukt\Router\Middleware\Authorization::class,
));

$app->post("/login", function(Strukt\Http\Request $request){

    $username = $request->get("username");
    $password = $request->get("password");

    $request->getSession()->set("username", $username);

    return new Strukt\Http\Response\Plain(sprintf("User %s logged in.", $username));
});

$app->get("/current/user", function(Strukt\Http\Request $request){

    return $request->getSession()->get("username");
});

$app->get("/logout", function(Strukt\Http\Request $request){

    $request->getSession()->invalidate();

    return new Strukt\Http\Response\Plain("User logged out.");
});

exit($app->run());
```

### Environment

[](#environment)

After installation run `composer exec static` to get `public\` directory.

```
    public/
    ├── errors
    │   ├── 403.html
    │   ├── 404.html
    │   ├── 405.html
    │   └── 500.html
    └── static
        ├── css
        │   └── style.css
        ├── index.html
        └── js
            └── script.js

```

### Apache

[](#apache)

`.htaccess` file:

```
DirectoryIndex index.php

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

```

BTW, DB Tip...
--------------

[](#btw-db-tip)

[Adminer](adminer.org) is a really neat tool! It is a single file dba and can be placed under a router easily! Download the adminer.php file and place in root folder.

```
$app->any("/dba", function(Request $request){

    include "./adminer-x.x.x.php";

    return new Strukt\Http\Response\Plain();
});
```

Cheers!

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance62

Regular maintenance activity

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 98.4% 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 ~163 days

Recently: every ~282 days

Total

8

Last Release

397d ago

PHP version history (3 changes)v1.0.0-alphaPHP ^7.1.3

v1.1.0-alphaPHP ^7.4

v1.1.4-alphaPHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f77a56030c77ce25f7fcf6db800e45bb6a31bf3c07740b43aeabcdf5e9edec2?d=identicon)[pitsolu](/maintainers/pitsolu)

---

Top Contributors

[![pitsolu](https://avatars.githubusercontent.com/u/16669704?v=4)](https://github.com/pitsolu "pitsolu (185 commits)")[![samweru](https://avatars.githubusercontent.com/u/104033121?v=4)](https://github.com/samweru "samweru (3 commits)")

---

Tags

annotationshttp-routerrest-api

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/strukt-router/health.svg)

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

###  Alternatives

[symfony/http-kernel

Provides a structured process for converting a Request into a Response

8.1k822.4M6.8k](/packages/symfony-http-kernel)[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M233](/packages/nelmio-api-doc-bundle)[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k48.1M236](/packages/api-platform-core)[friendsofsymfony/http-cache-bundle

Set path based HTTP cache headers and send invalidation requests to your HTTP cache

43813.2M47](/packages/friendsofsymfony-http-cache-bundle)[illuminate/http

The Illuminate Http package.

11936.0M5.1k](/packages/illuminate-http)[api-platform/http-cache

API Platform HttpCache component

223.2M7](/packages/api-platform-http-cache)

PHPackages © 2026

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