mammatus / http-server-webroot
HTTP Server webroot implementations
Package info
github.com/MammatusPHP/http-server-webroot
Language:Makefile
pkg:composer/mammatus/http-server-webroot
Requires
- php: ^8.4
- mammatus/http-server-contracts: ^0.1.0
Requires (Dev)
- wyrihaximus/makefiles: ^0.14.8
- wyrihaximus/test-utilities: ^14.4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-27 16:17:04 UTC
README
Concrete types for the Webroot marker interface from mammatus/http-server-contracts. Return one from Vhost::webroot(); mammatus/http-server passes a filesystem directory into generated ReactPHP servers only when the value is a WebrootPath.
Install
To install via Composer, use the command below, it will automatically detect the latest version and bind it with ^.
composer require mammatus/http-server-webroot
Implementations
This package provides the following classes:
NoWebroot
Empty implementation of Webroot. Use it when the vhost serves only dynamic routes and handlers (no static files). Generated server configuration receives an empty webroot path.
use Mammatus\Http\Server\Configuration\Vhost; use Mammatus\Http\Server\Configuration\Webroot; use Mammatus\Http\Server\Webroot\NoWebroot; final class FrontendVhost implements Vhost { public static function webroot(): Webroot { return new NoWebroot(); } // port(), name(), maxConcurrentRequests(), middleware(), ... }
Example: FrontendVhost.
WebrootPath
Readonly value object holding a directory path. Call path() to read the absolute or relative filesystem location served as static content.
use Mammatus\Http\Server\Configuration\Vhost; use Mammatus\Http\Server\Webroot\WebrootPath; final class HealthCheckVhost implements Vhost { public static function webroot(): WebrootPath { return new WebrootPath(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'public'); } // port(), name(), maxConcurrentRequests(), middleware(), ... }
Example: HealthCheckVhost. Wiring in the server plugin: Collector.
License
The MIT License (MIT)
Copyright (c) 2026 Cees-Jan Kiewiet
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.