cloud-castle / http-dev-server
Встроенный PHP-сервер разработки: front controller, статика и запуск php -S поверх PSR-7/15.
Requires
- php: >=8.1
- cloud-castle/http-response: ^1.1
- psr/http-message: ^2.0
Requires (Dev)
- deptrac/deptrac: ^3.0 || ^4.0
- ergebnis/composer-normalize: ^2.45
- friendsofphp/php-cs-fixer: ^3.75
- icanhazstring/composer-unused: ^0.9
- infection/infection: ^0.29 || ^0.33
- php-parallel-lint/php-parallel-lint: ^1.4
- phpmd/phpmd: ^2.15
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^1.12 || ^2.1
- phpstan/phpstan-deprecation-rules: ^1.2 || ^2.0
- phpstan/phpstan-phpunit: ^1.4 || ^2.0
- phpstan/phpstan-strict-rules: ^1.6 || ^2.0
- phpunit/phpunit: ^10.5 || ^11.5
- psalm/plugin-phpunit: ^0.19 || ^0.20
- rector/rector: ^1.2 || ^2.0
- roave/security-advisories: dev-latest
- squizlabs/php_codesniffer: ^3.12 || ^4.0
- vimeo/psalm: ^6.0
- webmozart/assert: ^1.11
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-06 14:48:40 UTC
README
🇷🇺 Русский · 🇬🇧 English · 🇩🇪 Deutsch · 🇫🇷 Français · 🇪🇸 Español · 🇮🇹 Italiano
CloudCastle Http DevServer
Встроенный PHP-сервер разработки: front controller, статика и запуск
php -Sповерх PSR-7/15.
Установка
composer require cloud-castle/http-dev-server
Требуется PHP 8.1+ и cloud-castle/http-response ^1.1.
Быстрый старт
<?php
use CloudCastle\Http\DevServer\BuiltInServer;
use CloudCastle\Http\DevServer\BuiltInServerConfig;
use CloudCastle\Http\DevServer\FrontController;
use CloudCastle\Http\DevServer\PhpBuiltInRouter;
use CloudCastle\Http\DevServer\StaticPathResolver;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
$handler = static function (ServerRequestInterface $request): ResponseInterface {
// вернуть PSR-7 Response (например из HttpKernel::handle)
};
$front = new FrontController($handler);
$router = new PhpBuiltInRouter(new StaticPathResolver(__DIR__ . '/public'), $front);
// router.php для php -S:
// return $router->handle();
$config = new BuiltInServerConfig('127.0.0.1', 8080, __DIR__ . '/public', __DIR__ . '/router.php');
(new BuiltInServer($config))->start();
Возможности
- Front controller:
ServerRequestFactory::fromGlobals→ handler → SAPI emit - Роутер
php -Sс безопасной раздачей статики - Запуск встроенного сервера с подменяемым process runner (для тестов)
Плюсы и минусы
Плюсы: тонкий слой над уже готовым http-response; без лишних runtime-зависимостей; удобно стыкуется с http-kernel через callable.
Минусы: только для разработки (php -S); пакет моложе аналогов вроде Symfony CLI server.
Когда применять
Локальный запуск микрофреймворка CloudCastle на PSR-7 без nginx/Apache.
Разработка
composer install
composer check
Лицензия
MIT © CloudCastle