- Монгол | 2. English | 3. Getting Started
Цэвэр, минимал, объект хандалтат бүтэцтэй HTTP Message компонент (PSR-7).
codesaur/http-message нь codesaur ecosystem-ийн нэг хэсэг бөгөөд PHP-ийн PSR-7 стандартын дагуу Request, Response, ServerRequest, URI, Stream, UploadedFile, OutputBuffer зэрэг HTTP мессежийн бүрэлдэхүүнүүдийг хэрэгжүүлсэн бага жинтэй компонент юм.
Багц нь дараах үндсэн классуудаас бүрдэнэ:
- Message - PSR-7 MessageInterface хэрэгжилт (headers, protocol, body)
- Request - PSR-7 RequestInterface
- Response - PSR-7 ResponseInterface
- ServerRequest - Глобал орчноос request сэргээдэг advanced implementation
- Uri - PSR-7 UriInterface
- Stream - PSR-7 StreamInterface хэрэгжилт
- UploadedFile - Upload хийгдсэн файлын metadata + moveTo()
- Output - StreamInterface хэрэгжилт (output buffering)
- Бүрэн танилцуулга - Суурилуулалт, хэрэглээ, жишээнүүд
- API тайлбар - Бүх метод, exception-үүдийн тайлбар
- Шалгалтын тайлан - Код шалгалтын тайлан
Clean, minimal, object-oriented HTTP Message component (PSR-7). A lightweight component that implements HTTP message components following PHP's PSR-7 standard, including Request, Response, ServerRequest, URI, Stream, UploadedFile, OutputBuffer, and more.
codesaur/http-message is part of the codesaur ecosystem and is a lightweight PHP component that can be used standalone, independent of any framework.
The package consists of the following core classes:
- Message - PSR-7 MessageInterface implementation (headers, protocol, body)
- Request - PSR-7 RequestInterface
- Response - PSR-7 ResponseInterface
- ServerRequest - Advanced implementation that reconstructs request from global environment
- Uri - PSR-7 UriInterface
- Stream - PSR-7 StreamInterface implementation
- UploadedFile - Uploaded file metadata + moveTo()
- Output - StreamInterface implementation (output buffering)
- Full Documentation - Installation, usage, examples
- API Reference - Complete API documentation
- Review - Code review report
- PHP 8.2.1+
- ext-json PHP extension
- Composer
Composer ашиглан суулгана / Install via Composer:
composer require codesaur/http-messageuse codesaur\Http\Message\ServerRequest;
use codesaur\Http\Message\Response;
// ServerRequest үүсгэх / Create ServerRequest
$request = (new ServerRequest())->initFromGlobal();
// Query params
var_dump($request->getQueryParams());
// PSR-7 headers унших / Read PSR-7 headers
$contentType = $request->getHeaderLine('Content-Type');
$csrfToken = $request->getHeaderLine('X-CSRF-TOKEN');
// Response үүсгэх / Create Response
$response = (new Response())
->withStatus(200)
->withHeader('Content-Type', 'application/json');
// Body-д бичих / Write to body
$response->getBody()->write(json_encode(['message' => 'Hello, World!']));Тест ажиллуулах / Run tests:
# Бүх тестүүдийг ажиллуулах / Run all tests
composer test
# Coverage-тэй тест ажиллуулах / Run tests with coverage
composer test-coverage- CHANGELOG.md - Full version history
This project is licensed under the MIT License.
Narankhuu codesaur@gmail.com https://github.com/codesaur
codesaur ecosystem: https://codesaur.net