From 8fe15ac7d48995555435f0e9dcbceee6afa22a89 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 13 May 2010 22:56:10 +0200 Subject: [PATCH] modified: LICENSE modified: README fixed port at examples/hello_world.php new simplified version of examples/hello_world_forks.php --- LICENSE | 2 +- README | 52 ++++++++++++------------ examples/fill_server_variables.php | 71 -------------------------------- examples/hello_world.php | 4 +- examples/hello_world_forks.php | 83 +++++++++++++++++--------------------- examples/mistral.php | 58 -------------------------- 6 files changed, 65 insertions(+), 205 deletions(-) delete mode 100644 examples/fill_server_variables.php rewrite examples/hello_world_forks.php (88%) delete mode 100644 examples/mistral.php diff --git a/LICENSE b/LICENSE index e5d224f..f6584f4 100644 --- a/LICENSE +++ b/LICENSE @@ -1 +1 @@ -The license debat has not yet been started. So for now the license will be LGPL. +The license debate has not yet been started. So for now the license will be LGPL. diff --git a/README b/README index 076f8ac..25cdb65 100644 --- a/README +++ b/README @@ -1,10 +1,9 @@ Mistral - - +------- The PHP extension you have in front of you allows you to run a -webserver from inside PHP. This allows you to run a standalone -application as server, giving it all the benefits of an easy -to learn and write language plus secure deployment. +webserver from inside your PHP application. This allows you to +run a standalone application as server, giving it all the benefits +of an easy to learn and write language plus secure deployment. It is currently /in development/, this means that the code you can find here is not ready for production yet, unless you are @@ -14,33 +13,34 @@ could be encountered is out of memory situations because of garbage collector incidents. This code has been written because of /extreme/ performance -improvements in compare to a standard SAPI clients or HipHop. +improvements in comparison to standard SAPI clients like FastCGI +or mod_php. We suggest you to use this code behind a reverse proxy such -as Varnish or Cherokee. - - -Dependencies; -The code requires libev to compile and run, and gets is major -speed improvement from this great framework. - +as Varnish, haproxy or the Cherokee Webserver. -How to use; -phpize -./configure -make -make install -add extension=mistral.so to your php.ini, see the examples -directory for the typical Hello World type of application. +Dependencies +------------ +The code requires libev to compile and run, and gets it's major +speed improvement from this great library. -Known issues; -Memory usage might become a problem. +Installation +------------ +1.) phpize +2.) ./configure +3.) make +4.) make install +5.) add extension=mistral.so to your php.ini, see the examples + directory for the typical Hello World type of application. -Stefan de Konink, 2010-02-21 +We hope you find this extension useful and +you will create high performance web sites using it +Stefan de Konink & Michael Maier, 2010-05-13 -Information request; -German/English -- Michael -Dutch/English -- Stefan +Information request +------------------- +Dutch/English -- Stefan (stefan@konink.de) +German/English -- Michael (maier@b2host.de) \ No newline at end of file diff --git a/examples/fill_server_variables.php b/examples/fill_server_variables.php deleted file mode 100644 index c3be5cf..0000000 --- a/examples/fill_server_variables.php +++ /dev/null @@ -1,71 +0,0 @@ - time()-$keepAliveTimeout) && ($input = fgets($conn) ) != "\r\n" ) { - while( !feof($conn) && ($input = fgets($conn) ) != "\r\n" ) { - if( preg_match('/([^:]+): (.*)/', $input, $matches) ) { - $HTTP_HEADERS[ strtolower($matches[1]) ] = trim($matches[2]); - } - } - - if( count($HTTP_HEADERS) ) { - $_SERVER['REQUEST_METHOD'] = strtoupper( $inputParsed[0] ); - $_SERVER['REQUEST_URI'] = $inputParsed[1]; - $_SERVER['SERVER_PROTOCOL'] = strtoupper( $inputParsed[2] ); - - $remoteIp = explode( ':', stream_socket_get_name( $conn, true ) ); - $_SERVER['REMOTE_ADDR'] = $remoteIp[0]; - $_SERVER['REMOTE_PORT'] = $remoteIp[1]; - - $_SERVER['HTTP_HOST'] = $HTTP_HEADERS['host']; - $_SERVER['HTTP_USER_AGENT'] = $HTTP_HEADERS['user-agent']; - $_SERVER['HTTP_ACCEPT'] = $HTTP_HEADERS['accept']; - $_SERVER['HTTP_ACCEPT_LANGUAGE'] = $HTTP_HEADERS['accept-language']; - $_SERVER['HTTP_ACCEPT_ENCODING'] = $HTTP_HEADERS['accept-encoding']; - $_SERVER['HTTP_ACCEPT_CHARSET'] = $HTTP_HEADERS['accept-charset']; - $_SERVER['HTTP_KEEP_ALIVE'] = $HTTP_HEADERS['keep-alive']; - $_SERVER['HTTP_CONNECTION'] = $HTTP_HEADERS['connection']; - $_SERVER['HTTP_COOKIE'] = $HTTP_HEADERS['cookie']; - - $_SERVER['SERVER_SOFTWARE'] = '/^_^\istral Enterprise PHP v1.00'; - - $parsed_uri = parse_url($_SERVER['REQUEST_URI']); - parse_str($parsed_uri['query'], $_GET); - - $_SERVER['argv'] = array(0 => $parsed_uri['query']); - $_SERVER['argc'] = count($_SERVER['argv']); - $_SERVER['GATEWAY_INTERFACE'] = 'CGI/1.1'; - $_SERVER['SCRIPT_NAME'] = $parsed_uri['path']; - $_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME']; - $_SERVER['QUERY_STRING'] = $parsed_uri['query']; - - //print_r($_SERVER); - //print_r($_GET); - //print_r($parsed_uri); - - // Determine supported compression method - $gzip = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'); - $deflate = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate'); - $encoding = $gzip ? 'gzip' : ($deflate ? 'deflate' : 'none'); - - // Check for buggy versions of Internet Explorer - if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Opera') && - preg_match('/^Mozilla\/4\.0 \(compatible; MSIE ([0-9]\.[0-9])/i', $_SERVER['HTTP_USER_AGENT'], $matches)) { - $version = floatval($matches[1]); - - if ($version < 6) - $encoding = 'none'; - - if ($version == 6 && !strstr($_SERVER['HTTP_USER_AGENT'], 'EV1')) - $encoding = 'none'; - } - } -?> diff --git a/examples/hello_world.php b/examples/hello_world.php index ae68f11..00b009c 100644 --- a/examples/hello_world.php +++ b/examples/hello_world.php @@ -5,8 +5,8 @@ function my_cool_callback($http_request) { return array('status_code' => '200 OK', 'connection' => 'close', 'content-type' => 'text/plain', 'body' => 'Hello World'); } -# Bind Webserver on all ips with port 8802, timeout > 0 == keep-alive -mistral_init('0.0.0.0', 6901, 0); +# Bind Webserver on all ips with port 8081, timeout > 0 == keep-alive +mistral_init('0.0.0.0', 8081, 0); # Setup callback function which gets called after each client request mistral_register_callback("my_cool_callback"); diff --git a/examples/hello_world_forks.php b/examples/hello_world_forks.php dissimilarity index 88% index 8e09683..9571cbe 100644 --- a/examples/hello_world_forks.php +++ b/examples/hello_world_forks.php @@ -1,47 +1,36 @@ - '200 OK', - 'connection' => $_SERVER['HTTP_CONNECTION'], - 'content-type' => 'text/html', - 'content-length' => strlen($output), - 'body' => $output); - return $answer; - } -} - - -$maxChildren = 4; -$startport = 8080; -while( $cntChildren < $maxChildren ) { - $cntChildren++; - $startport++; - - $pid = pcntl_fork(); - if ($pid == -1) { - echo "Warning: Cannot spawn child process!!!\n"; - } - elseif($pid) { - // Parent process - } - else { - echo 'Spawn Child [' . getMyPid() . '] Port ' . $startport . "\n"; - $app = new HelloWorldApp('0.0.0.0', $startport, 3); - $app->register_callback('HelloWorldApp::main'); - $app->run(); - } -} - -while(true) { - sleep(1); -} -?> + '200 OK', + 'connection' => $requests['HTTP_CONNECTION'], + 'content-type' => 'text/html', + 'content-length' => strlen($output), + 'body' => $output); + return $answer; +} + +$maxChildren = 4; +$startport = 8080; +while( $cntChildren < $maxChildren ) { + $cntChildren++; + $startport++; + + $pid = pcntl_fork(); + if ($pid == -1) { + echo "Warning: Cannot spawn child process!!!\n"; + } elseif($pid) { + // Parent process + } else { + echo 'Spawn Child [' . getMyPid() . '] Port ' . $startport . "\n"; + mistral_init('0.0.0.0', $startport, 5); + mistral_register_callback('my_cool_callback'); + mistral_start(); + } +} + +while(true) { + sleep(1); +} +?> diff --git a/examples/mistral.php b/examples/mistral.php deleted file mode 100644 index 2cc026c..0000000 --- a/examples/mistral.php +++ /dev/null @@ -1,58 +0,0 @@ - $parsed_uri['query']); - $_SERVER['argc'] = count($_SERVER['argv']); - $_SERVER['GATEWAY_INTERFACE'] = 'CGI/1.1'; - $_SERVER['SCRIPT_NAME'] = $parsed_uri['path']; - $_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME']; - $_SERVER['PATH_TRANSLATED'] = __PATH__; - $_SERVER['QUERY_STRING'] = $parsed_uri['query']; - $_SERVER['DOCUMENT_ROOT'] = '/'; - if( !isset($_SERVER['HTTP_CONNECTION']) ) { - $_SERVER['HTTP_CONNECTION'] = $_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.1' ? 'keep-alive' : 'close'; - } - } -} -?> -- 2.11.4.GIT