PHPackages                             devvime/modpath - 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. devvime/modpath

ActiveLibrary[Framework](/categories/framework)

devvime/modpath
===============

A Minimal and Expressive PHP Micro Routing Framework

v1.0.27(3mo ago)151MITPHP

Since May 31Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/devvime/modpath-php)[ Packagist](https://packagist.org/packages/devvime/modpath)[ RSS](/packages/devvime-modpath/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (29)Used By (0)

ModPath PHP
===========

[](#modpath-php)

### A Minimal and Expressive PHP Micro Routing Framework

[](#a-minimal-and-expressive-php-micro-routing-framework)

---

📦 Installation
--------------

[](#-installation)

```
composer require devvime/modpath
```

---

⚙️ Initial Configuration
------------------------

[](#️-initial-configuration)

```
require dirname(__DIR__) . '/vendor/autoload.php';

use ModPath\Router\Router;
use ModPath\Controllers\UserController;
use ModPath\Controllers\ProductController;

$router = new Router();

$router->registerRoutes([
    UserController::class,
    ProductController::class,
]);

$router->dispatch();
```

---

🧽 Defining a Controller with Routes and Middleware
--------------------------------------------------

[](#-defining-a-controller-with-routes-and-middleware)

```
namespace ModPath\Controllers;

use ModPath\View\View;
use ModPath\Attribute\Route;
use ModPath\Attribute\Controller;
use ModPath\Attribute\Middleware;
use ModPath\Interface\ControllerInterface;
use ModPath\Middleware\AuthMiddleware;
use ModPath\Middleware\PermissionMiddleware;
use ModPath\Services\UserService;

// Optional: Define a route controller and middleware for all routes in the controller
#[Controller(path: '/user', middleware: AuthMiddleware::class)]
class UserController implements ControllerInterface
{
    public function __construct() {}

    #[Route(path: '', method: 'GET')]
    public function index($request, $response): void
    {
        $response->send('Users list');
    }

    #[Route(path: '/{id}', method: 'GET')]
    public function show($request, $response): void
    {
        $response->send("Info for user id: {$request->params['id']}");
    }

    #[Route(path: '', method: 'POST')]
    public function store($request, $response): void
    {
        $response->send("Storing new user");
    }

    #[Route(path: '/{id}', method: 'PUT')]
    public function update($request, $response): void
    {
        $response->send("Updating user id: {$request->params['id']}");
    }

    #[Route(path: '/{id}', method: 'DELETE')]
    public function destroy($request, $response): void
    {
        $response->send("Deleting user id: {$request->params['id']}");
    }
}
```

---

📥 Request Parameters
--------------------

[](#-request-parameters)

```
#[Route(path: 'user/{id}', method: 'POST')]
public function store($request, $response): void
{
    $request->params;   // URL parameters (e.g., $request->params['id'])
    $request->body;     // Parsed JSON body (e.g., $request->body->email)
    $request->query;    // Query string parameters (e.g., $_GET['key'])
    $request->headers;  // HTTP headers
}
```

---

📤 Response Handling
-------------------

[](#-response-handling)

```
#[Route(path: 'user/{id}', method: 'POST')]
#[Middleware(PermissionMiddleware::class)]
public function store($request, $response): void
{
    $response->send('Hello World!'); // Render plain text

    $response->render('views/index', ["mesage" => "Hello world!"]); // Render HTML template

    $response->json([
        'status' => 200,
        'message' => 'Hello World!'
    ]); // Return JSON response
}
```

---

🛡️ Middleware Structure
-----------------------

[](#️-middleware-structure)

All middleware classes must be placed under `ModPath\Middleware` and implement the `MiddlewareInterface`. The `handle()` method is required and must return a boolean indicating whether to continue the request.

```
namespace ModPath\Middleware;

use ModPath\Interface\MiddlewareInterface;

class AuthMiddleware implements MiddlewareInterface
{
    public function handle(): bool
    {
        // Authentication logic here
        return true;
    }
}
```

---

🧹 Template Engine Syntax
------------------------

[](#-template-engine-syntax)

### Display Variables

[](#display-variables)

```
User Details
ID: {{ $id }}
Name: {{ $name }}
```

### Loops

[](#loops)

```
User List

        {{ $user }}

```

Equivalent to:

```

```

### Conditions

[](#conditions)

```

    Values are equal
 $b)>
    A is greater than B

    Values are different

```

---

### Summary of Template Syntax

[](#summary-of-template-syntax)

FeatureCustom Syntax ExamplePHP EquivalentDisplay`{{ $name }}```If` $b)> ... `` ... `Elseif/Else` ...  ...`` ... `Loop` ... `` ... `For``---

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance80

Actively maintained with recent releases

Popularity10

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

Recently: every ~3 days

Total

28

Last Release

105d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/871c18b0694a44cddfb5c7182d29672cb901836d53f72113fe0893a35384c8b7?d=identicon)[devvime](/maintainers/devvime)

---

Top Contributors

[![devvime](https://avatars.githubusercontent.com/u/36117649?v=4)](https://github.com/devvime "devvime (38 commits)")

### Embed Badge

![Health badge](/badges/devvime-modpath/health.svg)

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

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[chameleon-system/chameleon-base

The Chameleon System core.

1026.5k3](/packages/chameleon-system-chameleon-base)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)[doppar/framework

The Doppar Framework

366.7k8](/packages/doppar-framework)

PHPackages © 2026

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