Last Updated | | Ratings | | Unique User Downloads | | Download Rankings |
2016-04-23 (10 months ago) | | Not enough user ratings | | Total: 453 | | All time: 5,877 This week: 1,113 |
|
Description | | Author |
This package implements a HTTP server that can take virtual host requests.
It can listen to HTTP requests in a given port of the local machine and handle the requests serving files of the server machine.
The server can handle requests to multiple virtual host names according to definitions read from a separate configuration file.
The request path may be rewritten according to rules defined in the configuration.
Requests that map to files with the .php file name extension will cause the server to execute respective PHP scripts to generate the request response.
It can also cache the responses of requests that match a given path pattern.
Responses can be compressed with the gzip or deflate methods if defined in the configuration. Innovation Award
March 2015
Number 4
Prize: One copy of the Zend Studio |
HTTP servers are very common but they are often separate programs that you need to install to use together with PHP.
Nowadays PHP comes with a built-in HTTP server but it is still very limited.
This class implements a pure PHP HTTP server that implements more complex features like virtual host support, URL rewriting, caching, etc..
Manuel Lemos |
| |
|
|
Innovation award
Nominee: 10x
Winner: 1x |
|
Details
HttpServer
This is a http server for PHP completely written in PHP - HttpServer.
> Why do you do this?
> - Because I can.
Features
- Different hostnames.
- GET and POST requests.
- PHP files starting (with properly filled _SERVER, _POST, _GET, _COOKIE) and static files downloading.
- Forking on any request to avoid delays.
- Compression gzip, deflate.
Configuration
All configuration in file httpserver.configuration.
It has blocks and directives inside blocks.
For example, this is default configuration:
global:
listen 80
wapcode.ru:
document_root C:\Users\User\Documents;
match *.(png|jpe?g|gif):
cache 30d;
replace (.+) /index.php?$1 not_exist;
default:
document_root C:\Users\User\Documents;
compress gzip,deflate;
global.conf:
document_root C:\Users\User\global.conf;
Some special host names:
- global - is not a hostname. It is server configuration.
- default - is default hostname. If user did not provide host this host will be used.
Server configuration
Inside server configuration following directives available.
Hosts configuration
Inside a block following directives available.
- document_root [folder].
> Specifies root folder for hostname. Must not end with slash.
- replace [what] [with that] [flags].
> Allows replace requested path with regular expressions. First argument is an regular expression. Second is a destination path. (Must start with slash). Last arg is flags. not_exist flag changes behavior of replacement: if requested path exist, even if path matches expression, replacement will not be performed.
- compress [methods].
> Sets available compression methods for response generation. Available: gzip,defalte.
- match [regex].
> Specifies additional directives for special path(s).
- cache [cache timeout].
> Tells server to add Cache header in response.
Usage
- Download and unpack archive
- Update with composer (
composer update
)
- Run bin/httpserver (
php bin/httpserver
)
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.