phramz / staticfiles
This library will serve static files from a local directory
Installs: 52
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/phramz/staticfiles
Requires
- php: >=5.5.9
- psr/log: ~1.0
- symfony/http-foundation: ~2.1
- symfony/http-kernel: ~2.1
- webmozart/path-util: ~2.1
Requires (Dev)
- phpunit/phpunit: ~4.1
- symfony/var-dumper: ~2.6
This package is not auto-updated.
Last update: 2023-03-18 10:19:15 UTC
README
Staticfiles HttpServer acts like a simple webserver that serves static files from a local directory.
Install
Install with Composer:
$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar require phramz/staticfiles
Example
The first example shows how to use Staticfiles as standalone application.
<?php use Symfony\Component\HttpFoundation\Request; // your static files will be served from this folder $webroot = '/var/www'; // if we cannot guess the files mime-type we'll use this default $defaultMimetype = 'application/octed-stream'; // files with the following extensions will not be delivered. We'll get a 404 instead. $exclude = ['php', 'key']; // let's build our application $app = new Phramz\Staticfiles\HttpServer($webroot, $defaultMimetype, $exclude); // dispatch the request $request = Request::createFromGlobals(); $response = $app->handle($request); $response->send(); // and shutdown $app->terminate($request, $response);
LICENSE
This project is under MIT license. Please read the LICENSE file for further information.
Credits
Some of the 3rd party libraries in use: