PHPackages                             codesaur/http-application - 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. codesaur/http-application

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

codesaur/http-application
=========================

PSR-7 &amp; PSR-15 нийцсэн хөнгөн, уян хатан HTTP Application цөм

v6.0.2(2mo ago)1612↓50%1MITPHPCI passing

Since Mar 15Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/codesaur-php/HTTP-Application)[ Packagist](https://packagist.org/packages/codesaur/http-application)[ Docs](https://github.com/codesaur-php)[ RSS](/packages/codesaur-http-application/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (77)Used By (1)

codesaur/http-application
=========================

[](#codesaurhttp-application)

[![CI](https://github.com/codesaur-php/HTTP-Application/workflows/CI/badge.svg)](https://github.com/codesaur-php/HTTP-Application/actions)[![PHP Version](https://camo.githubusercontent.com/1015683ef28e870620edc19b6e22b456c0dc170c260fa4645905e93438f607a6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e322e312d3737374242342e7376673f6c6f676f3d706870)](https://www.php.net/)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

**PSR-7 &amp; PSR-15 нийцсэн хөнгөн, уян хатан HTTP Application цөм****Lightweight, flexible HTTP Application core compliant with PSR-7 &amp; PSR-15**

---

Агуулга / Table of Contents
---------------------------

[](#агуулга--table-of-contents)

1. [Монгол](#1-%D0%BC%D0%BE%D0%BD%D0%B3%D0%BE%D0%BB-%D1%82%D0%B0%D0%B9%D0%BB%D0%B1%D0%B0%D1%80) | 2. [English](#2-english-description) | 3. [Getting Started](#3-getting-started)

---

1. Монгол тайлбар
-----------------

[](#1-монгол-тайлбар)

`codesaur/http-application` нь PSR-7 (HTTP Message) ба PSR-15 (HTTP Server RequestHandler/Middleware) стандартууд дээр суурилсан **минималист**, **өндөр уян хатан**, **middleware суурьтай** Application цөм юм.

Та хүсвэл:

- Router нэмэх
- Middleware удирдах
- Controller/action ашиглах
- Closure route ашиглах
- Exception handler бүртгэх
- Custom request attributes ашиглах

гэх мэтээр өөрийн хүссэн бүтэцтэй web application-ийг хэдхэн мөр кодоор босгох боломжтой.

### Гол боломжууд

[](#гол-боломжууд)

- PSR-7 стандартын ServerRequest + Response
- PSR-15 Middleware &amp; RequestHandler гинжин бүтэц
- Уян хатан Router интеграци (codesaur/router)
- Controller суурь класс (MVC хэв маяг дэмжлэг)
- Exception Handler (development mode-той)
- Хэт хөнгөн, хурдан

### Дэлгэрэнгүй мэдээлэл

[](#дэлгэрэнгүй-мэдээлэл)

- [Бүрэн танилцуулга](docs/mn/README.md) - Суурилуулалт, хэрэглээ, жишээнүүд
- [API тайлбар](docs/mn/api.md) - Бүх метод, exception-үүдийн тайлбар
- [Шалгалтын тайлан](docs/mn/review.md) - Код шалгалтын тайлан

---

2. English Description
----------------------

[](#2-english-description)

`codesaur/http-application` is a **minimalist**, **highly flexible**, **middleware-based** Application core built on PSR-7 (HTTP Message) and PSR-15 (HTTP Server RequestHandler/Middleware) standards.

You can:

- Add Router
- Manage Middleware
- Use Controller/action
- Use Closure routes
- Register Exception handler
- Use Custom request attributes

and build your desired web application structure with just a few lines of code.

### Key Features

[](#key-features)

- PSR-7 Standard ServerRequest + Response
- PSR-15 Middleware &amp; RequestHandler Chain Structure
- Flexible Router Integration (codesaur/router)
- Controller Base Class (MVC pattern support)
- Exception Handler (with development mode)
- Extremely Lightweight and Fast

### Documentation

[](#documentation)

- [Full Documentation](docs/en/README.md) - Installation, usage, examples
- [API Reference](docs/en/api.md) - Complete API documentation
- [Review](docs/en/review.md) - Complete package review and code quality assessment

---

3. Getting Started
------------------

[](#3-getting-started)

### Requirements

[](#requirements)

- PHP **8.2.1+**
- Composer
- PSR-7 compatible HTTP Message implementation (e.g., `codesaur/http-message`)

### Installation

[](#installation)

Composer ашиглан суулгана / Install via Composer:

```
composer require codesaur/http-application
```

### Quick Examples

[](#quick-examples)

#### Application - Basic Setup

[](#application---basic-setup)

```
use codesaur\Http\Application\Application;
use codesaur\Http\Application\ExceptionHandler;
use codesaur\Http\Message\ServerRequest;

// Application instance үүсгэх / Create Application instance
$app = new Application();

// Exception handler бүртгэх / Register exception handler
$app->use(new ExceptionHandler());

// Route бүртгэх / Register route
$app->GET('/', function ($req) {
    echo 'Hello World!';
});

// Хүсэлт боловсруулах / Handle request
$request = (new ServerRequest())->initFromGlobal();
$response = $app->handle($request);
```

#### Router - Dynamic Routes

[](#router---dynamic-routes)

```
// Төрөлтэй параметртэй нэртэй route / Named route with typed parameters
$app->GET('/user/{int:id}', [UserController::class, 'show'])->name('user.show');

// Олон method-тэй route / Multi-method route
$app->POST_PUT('/api/users', [UserController::class, 'save']);

// Параметртэй Closure route / Closure route with parameters
$app->GET('/sum/{int:a}/{uint:b}', function ($req) {
    $params = $req->getAttribute('params');
    echo $params['a'] + $params['b'];
});
```

#### Controller - MVC Pattern

[](#controller---mvc-pattern)

```
use codesaur\Http\Application\Controller;

class UserController extends Controller
{
    public function show(int $id): void
    {
        $query = $this->getQueryParams();
        $page = $query['page'] ?? 1;

        echo "User ID: $id, Page: $page";
    }

    public function create(): void
    {
        $data = $this->getParsedBody();
        $name = $data['name'] ?? 'Unknown';

        echo "Created user: $name";
    }
}
```

#### Middleware - PSR-15 &amp; Closure

[](#middleware---psr-15--closure)

```
// PSR-15 Middleware
class AuthMiddleware implements MiddlewareInterface
{
    public function process($req, $handler): ResponseInterface
    {
        // Баталгаажуулалт шалгах / Check authentication
        if (!$this->isAuthenticated($req)) {
            return new Response(401);
        }

        return $handler->handle($req);
    }
}

$app->use(new AuthMiddleware());

// Closure Middleware
$app->use(function ($req, $handler) {
    $startTime = microtime(true);
    $response = $handler->handle($req);
    $duration = microtime(true) - $startTime;

    error_log("Request took: {$duration}s");
    return $response;
});
```

### Running Tests

[](#running-tests)

Тест ажиллуулах / Run tests:

```
# Бүх тестүүдийг ажиллуулах / Run all tests
composer test

# Зөвхөн unit тест / Unit tests only
composer test:unit

# Зөвхөн integration тест / Integration tests only
composer test:integration

# Coverage-тэй тест ажиллуулах / Run tests with coverage
composer test:coverage
```

---

Architecture
------------

[](#architecture)

```
Application
 +-- Middleware stack (PSR-15 + Closure)
 +-- Router (codesaur/router)
 +-- ExceptionHandler
 +-- Controller / Closure route executor

```

**Request Flow:** Application -&gt; Middleware -&gt; Match route -&gt; Controller/action/Closure -&gt; Response

---

Changelog
---------

[](#changelog)

- [CHANGELOG.md](CHANGELOG.md) - Full version history

Contributing &amp; Security
---------------------------

[](#contributing--security)

- [Contributing Guide](.github/CONTRIBUTING.md)
- [Security Policy](.github/SECURITY.md)

License
-------

[](#license)

This project is licensed under the MIT License.

Author
------

[](#author)

**Narankhuu**

**codesaur ecosystem:**

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance88

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity68

Established project with proven stability

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

Total

76

Last Release

61d ago

Major Versions

v1.2.1 → v2.02021-05-06

v2.5 → v3.02021-09-21

v3.1 → v4.02021-09-29

v4.7 → v5.02021-10-06

v5.9.0 → v6.0.02026-01-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/2281c1b7b23007da57ad0526923a5f822dea64629ab1cb70749188d2b869e55c?d=identicon)[codesaur](/maintainers/codesaur)

---

Top Contributors

[![codesaur](https://avatars.githubusercontent.com/u/4127594?v=4)](https://github.com/codesaur "codesaur (115 commits)")

---

Tags

httppsr-7routerpsr-15applicationcodesaurmongolmongolianarankhuucodenкодзаврнаранхүүкоденhttp applicationserver request handler

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codesaur-http-application/health.svg)

```
[![Health](https://phpackages.com/badges/codesaur-http-application/health.svg)](https://phpackages.com/packages/codesaur-http-application)
```

###  Alternatives

[middlewares/fast-route

Middleware to use FastRoute

96191.1k15](/packages/middlewares-fast-route)[sunrise/http-router

A powerful solution as the foundation of your project.

16249.8k10](/packages/sunrise-http-router)[mezzio/mezzio-authentication

Authentication middleware for Mezzio and PSR-7 applications

121.6M26](/packages/mezzio-mezzio-authentication)[middlewares/aura-router

Middleware to use Aura.Router

1110.9k3](/packages/middlewares-aura-router)[northwoods/router

Fast router for PSR-15 request handlers

161.4k](/packages/northwoods-router)

PHPackages © 2026

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