Download the PHP package tourze/psr15-static-file-request-handler without Composer
On this page you can find all versions of the php package tourze/psr15-static-file-request-handler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download tourze/psr15-static-file-request-handler
More information about tourze/psr15-static-file-request-handler
Files in tourze/psr15-static-file-request-handler
Download tourze/psr15-static-file-request-handler
More information about tourze/psr15-static-file-request-handler
Files in tourze/psr15-static-file-request-handler
Vendor tourze
Package psr15-static-file-request-handler
Short Description PSR-15 Static File Request Handler
License MIT
Package psr15-static-file-request-handler
Short Description PSR-15 Static File Request Handler
License MIT
Please rate this library. Is it a good library?
Informations about the package psr15-static-file-request-handler
PSR-15 Static File Request Handler
中文
A PSR-15 compatible request handler for serving static files efficiently in PHP applications. Supports cache headers, range requests, directory index, and MIME type detection.
Features
- PSR-15 compatible static file request handler
- Supports directory index (index.html, index.htm)
- MIME type auto-detection using league/mime-type-detection
- HTTP cache support (ETag, Last-Modified, 304 Not Modified)
- Range requests (partial content, 206)
- Prevents serving PHP files for security
- Easy integration with any PSR-15 middleware stack
Installation
Install via Composer:
Dependencies
Requirements:
- PHP >= 8.1
- Composer
Dependencies:
psr/http-message- PSR-7 HTTP message interfacespsr/http-server-handler- PSR-15 HTTP handlersleague/mime-type-detection- MIME type detectionnyholm/psr7- PSR-7 implementationsymfony/filesystem- File system operations
Quick Start
Example: Handling Range Requests
Documentation
Public API
- Constructor:
StaticFileRequestHandler::__construct(string $publicPath, ?Filesystem $filesystem = null) - Handler method:
handle(ServerRequestInterface $request): ResponseInterface
Response Codes
- 200 OK: File found and served successfully
- 206 Partial Content: Range request served successfully
- 304 Not Modified: File not modified (cache hit)
- 404 Not Found: File does not exist
- 416 Range Not Satisfiable: Invalid range request
- 500 Internal Server Error: File read error
Configuration
publicPath: The root directory for static files- Optionally pass a Symfony Filesystem instance
Advanced Usage
Custom Filesystem Integration
Middleware Integration
Cache Headers
The handler automatically sets cache headers:
ETagfor cache validationLast-Modifiedfor conditional requestsCache-Control: public, max-age=86400for browser caching
Range Request Support
Supports HTTP range requests for:
- Large file downloads
- Video streaming
- Progressive loading
Directory Index
Automatically serves index files:
index.html(preferred)index.htm(fallback)
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/fooBar) - Commit your changes (
git commit -am 'Add some fooBar') - Push to the branch (
git push origin feature/fooBar) - Create a new Pull Request
Coding Style: PSR-12
Testing:
License
MIT License. See LICENSE for details.
Changelog
See Releases for version history and upgrade notes.
All versions of psr15-static-file-request-handler with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.1
psr/http-message Version ^1.1 || ^2.0
psr/http-server-handler Version ^1.0
nyholm/psr7 Version ^1.8.2
league/mime-type-detection Version ^1.0
symfony/filesystem Version ^6.4
psr/http-message Version ^1.1 || ^2.0
psr/http-server-handler Version ^1.0
nyholm/psr7 Version ^1.8.2
league/mime-type-detection Version ^1.0
symfony/filesystem Version ^6.4
The package tourze/psr15-static-file-request-handler contains the following files
Loading the files please wait ...