PHPackages                             laikait/laika-route - 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. laikait/laika-route

ActiveLibrary[Framework](/categories/framework)

laikait/laika-route
===================

Routing package for Laika PHP MVC Framework.

v1.0.1(3d ago)041↑192.7%1MITPHP &gt;=8.1

Since Jul 5Compare

[ Source](https://github.com/laikait/laika-route)[ Packagist](https://packagist.org/packages/laikait/laika-route)[ RSS](/packages/laikait-laika-route/feed)WikiDiscussions Synced today

READMEChangelog (2)DependenciesVersions (4)Used By (1)

laika-route
===========

[](#laika-route)

Routing package for the Laika PHP MVC Framework.

Install
-------

[](#install)

```
composer require laikait/laika-route
```

Methods
-------

[](#methods)

```
use Laika\Route\Http;

Http::get('/users', 'UserController@index');
Http::post('/users', 'UserController@store');
Http::put('/users/{id}', 'UserController@update');
Http::patch('/users/{id}', 'UserController@patch');
Http::delete('/users/{id}', 'UserController@destroy');
Http::options('/users', 'UserController@options');
```

Route Params
------------

[](#route-params)

```
Http::get('/users/{id}', 'UserController@show');
Http::get('/users/{id:\d+}', 'UserController@show'); // regex constraint
```

Middleware
----------

[](#middleware)

```
// Single
Http::get('/dashboard', 'DashboardController@index')->middleware(['Auth']);

// Multiple
Http::get('/orders', 'OrderController@index')->middleware(['Auth', 'VerifiedEmail']);

// With args
Http::get('/admin', 'AdminController@index')->middleware(['Role|role=admin']);

// Multiple args
Http::get('/reports', 'ReportController@index')->middleware(['Throttle|limit=60,window=60']);

// Global (applies to all routes)
Http::globalMiddleware(['Csrf', 'Cors']);
```

Class:

```
namespace App\Middleware;

use Laika\Route\MiddlewareInterface;

class Role implements MiddlewareInterface
{
    public function handle(array $params, callable $next)
    {
        if (($_SESSION['role'] ?? null) !== ($params['role'] ?? null)) {
            http_response_code(403);
            return 'Forbidden'; // stops chain
        }
        return $next(); // continues chain
    }
}
```

- `$params` — route params + middleware config args (`role=admin`), merged, passed by reference through the whole chain (middleware → controller → afterware).
- Return value short-circuits the response if not `$next()`.

Afterware
---------

[](#afterware)

```
// Single
Http::get('/orders', 'OrderController@index')->afterware(['LogAccess']);

// Multiple
Http::get('/orders', 'OrderController@index')->afterware(['LogAccess', 'CacheResponse']);

// With args
Http::get('/reports', 'ReportController@index')->afterware(['LogAccess|level=info']);

// Global
Http::globalAfterware(['LogResponse']);
```

Class:

```
namespace App\Afterware;

use Laika\Route\AfterwareInterface;

class LogAccess implements AfterwareInterface
{
    public function terminate(array $params, $response): void
    {
        error_log('level=' . ($params['level'] ?? 'default'));
    }
}
```

Named Routes
------------

[](#named-routes)

```
Http::get('/users/{id}', 'UserController@show')->name('users.show');

$url = Http::url('users.show', ['id' => 5]); // /users/5
```

Groups
------

[](#groups)

```
// Basic
Http::group('admin', function () {
    Http::get('/dashboard', 'Admin\DashboardController@index');
});

// Nested (inherits parent's middleware/afterware)
Http::group('admin', function () {
    Http::group('billing', function () {
        Http::get('/invoices', 'Admin\Billing\InvoiceController@index');
    })->middleware(['Permission|perm=billing.view']);
})->middleware(['Auth']);

// Chained middleware + afterware (applied retroactively to all routes in group)
Http::group('api', function () {
    Http::post('/payments', 'PaymentController@store')->middleware(['ApiKey']);
})->middleware(['Cors'])->afterware(['LogApi']);
```

Fallback
--------

[](#fallback)

```
// Per group prefix
Http::fallback('admin', fn() => 'Admin route not found');

// Default (no prefix)
Http::fallback(null, fn() => 'Page not found');
```

Longest-prefix match; falls back to built-in `_404::show()` if nothing matches.

Dispatch
--------

[](#dispatch)

```
Http::dispatch();
```

Lifecycle: `preDispatcher()` → `registerInitiators()` (headers + hook files) → match route/asset/fallback → run middleware chain → run controller → run afterware chain.

Assets
------

[](#assets)

```
Dispatcher::registerAssetRoute('/style.css', __DIR__ . '/public/style.css');
```

API Reference
-------------

[](#api-reference)

ClassPurpose`Http`Static facade — routes, groups, middleware/afterware chaining, dispatch, named URLs`Handler`Route registry — storage, group stack, fallback, naming`Dispatcher`Request lifecycle, matching, asset serving, fallback resolution`Invoke`Middleware/afterware chain execution, controller resolution`Reflection`Named-argument injection for controllers`Url`URI normalization, pattern compiling, request matching`_404`Default 404 page`MiddlewareInterface``handle(array $params, callable $next)``AfterwareInterface``terminate(array $params, $response): void`License
-------

[](#license)

MIT — Showket Ahmed

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance99

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

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

3d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7272cd554fe8bf859b8450494f244927ee210cd95d516325fda55d33c74e5886?d=identicon)[riyadhtayf](/maintainers/riyadhtayf)

### Embed Badge

![Health badge](/badges/laikait-laika-route/health.svg)

```
[![Health](https://phpackages.com/badges/laikait-laika-route/health.svg)](https://phpackages.com/packages/laikait-laika-route)
```

###  Alternatives

[laravel/dusk

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

1.9k39.6M300](/packages/laravel-dusk)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

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