matthimatiker / stack-static-files
StackPHP middleware that serves static files from a configured asset directory.
Requires
- php: >=5.5.0
- symfony/http-foundation: ~2.3
- symfony/http-kernel: ~2.3
Requires (Dev)
- phpunit/phpunit: ~4.0
- satooshi/php-coveralls: ~0.6
- stack/builder: ^1.0.0
This package is not auto-updated.
Last update: 2024-12-07 19:44:28 UTC
README
Simple StackPHP middleware that serves files from a given directory. If the requested file does not exist, then the request is delegated to the next kernel.
Motivation
This middleware has been created to be able to use php-pm/php-pm with php-pm/php-pm-httpkernel as a standalone server. It avoided the need of nginx for serving static files.
Installation
This library is installed via Composer.
Add the following dependency to your composer.json
:
"require" : {
// ...
"matthimatiker/stack-static-files": "^0.0.1"
}
Concept
Usage
You can use stack/builder to compose your middleware stack:
$stack = (new Builder())->push(StaticFiles::class, __DIR__ . '/public-files');
$app = $stack->resolve($kernel);
Alternatively, you can combine kernel and middleware manually:
$app = new StaticFiles($kernel, __DIR__ . '/public-files');
Known Issues
Do not register a directory, which contains files that should not be served! This middleware has no security baked in and will serve any existing file, for example PHP scripts, VCS files etc.