PHP Classes

PHP Multi-Server: HTTP Server written in pure PHP

Recommend this page to a friend!
  Info   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 62%Total: 1,425 All time: 2,738 This week: 673Up
Version License PHP version Categories
php-multi-server 1.0GNU Lesser Genera...5.1Networking, HTTP, PHP 5, Unix
Description 

Author

This class implements an HTTP server written in pure PHP.

It starts a daemon that listen for connections and handles HTTP GET and HEAD requests.

The class can start children processes to handle multiple requests in parallel.

The requests may serve static files inside the document root directory. The class supports checking for modified files and return the appropriate responses for unchanged files.

Picture of Artur Graniszewski
  Performance   Level  
Name: Artur Graniszewski is available for providing paid consulting. Contact Artur Graniszewski .
Classes: 14 packages by
Country: Poland Poland
Age: 42
All time rank: 2874 in Poland Poland
Week rank: 112 Up3 in Poland Poland Up
Innovation award
Innovation award
Nominee: 7x

Winner: 1x

Recommendations

Create PHP desktop application
I would like to create PHP project for desktop computers

Details

phpMultiServer 1.0.0 lite INTRODUCTION --------------- This is a sample, high-performance HTTP server written in pure PHP. Thanks to various optimizations, this server is able to achieve ~800 HTTP requests/second on a dual core laptop (Core 2 Duo 1.6Ghz). This in turn allows you to create highly efficient PHP scripts with low response times (less than 1ms latency between sending request to launching PHP script). In result this software is sometimes faster than the Apache Server with mod_php which is written in highly efficient C language. Please note: this is just a 'lite', stripped version of the much larger solution, so the source code is not as flexible as in the original software. This little demo is a proof-of-concept and an educational example of network/inter-process programming in PHP. FEATURES ----------- * Supports GET/HEAD HTTP requests. * Highly efficient PHP code (up to 4 concurrent HTTP requests/1 CPU core ratio) * Basic security mechanisms (ie. server drops root privileges after launch, uses realpath() to protect itself against path traversal attacks) * Uses multicore processing (no CPU/memory limits) * Works as a daemon or CLI application. * Supports customizable index file names. * Supports If-Modified-Since header and '403 Not Modified' responses. * Supports some basic MIME types (you can add your own) * Provides configurable preforking mechanism (mimicking Apache HTTPD functionality) REQUIREMENTS --------------- This software works only in CLI (Command Line Interpreter) mode. It needs the root privileges to launch properly (after start phpMultiServer drops it's root privileges and switches it's effective UID to the standard, configurable user). Required PHP extensions: POSIX, Semaphore, PCNTL. CONFIGURATION ---------------- Server settings are stored in the server.php file, in a ServerConfig class. For starters: try to change these settings: ServerConfig::$documentRoot - stores the local path to the webpage directory (ie /home/users/drupal/public_html). ServerConfig::$serverRoot - stores the local path to the HTTP server directory (ie /root/server). ServerConfig::$socketAddress - stores the IP address of the server, which will be used for communication between server and the HTTP clients (ie 127.0.0.1 for localhost or 0.0.0.0 to listen on all available IP's) ServerConfig::$socketPort - stores the port number on which the HTTP server will listen for incoming connections (ie port 80). ServerConfig::$logFile - stores the path of log file used by this HTTP server. ServerConfig::$user, ServerConfig::$group - stores UID/GID of the unprivileged user, which will be used by the HTTP server (ie nobody/nobody) There is a bunch of other low level options too (documented in the sourcecode). HOW TO LAUNCH ---------------- Unpack the class, enter the class home directory and type below commands using the root privileges: php -f server.php start - starts the HTTP server (daemon mode) php -f server.php stop - stops the HTTP server php -f server.php debug - launches HTTP server in debug mode PRO VERSION -------------- Professional version includes additional functionalities like: * Gzip/deflate compression, POST requests and CGI support in HTTP wrapper. * Flexible source code (support for plugins and various protocols) * Supports various communication protocols (FTP/MySQL connection pooler/PDO proxy/POP3/IMAP/SMTP,SQLite over network) * Even more efficient PHP code. * SOAP server mode (with WSDL generator)

  Files folder image Files  
File Role Description
Plain text file server.php Class Main class
Accessible without login Plain text file readme.txt Doc. class documentation
Accessible without login Plain text file license.txt Lic. LGPL License
Accessible without login Plain text file benchmarks.txt Data Benchmark tests
Accessible without login Plain text file example.txt Data Example file

 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,425
This week:0
All time:2,738
This week:673Up
 User Ratings  
 
 All time
Utility:87%StarStarStarStarStar
Consistency:91%StarStarStarStarStar
Documentation:91%StarStarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:62%StarStarStarStar
Rank:961