This is a fork of marcj/php-pm.
What is different from the original repo, is that this PM is written specially for @RePHP framework, where asynchronous nature achieved based on PHP5.5 generators, and does not need any event libraries.
PHP-PM is a process manager for Request-Response Frameworks running in a @RePHP environment. The approach of this is to kill the expensive bootstrap of PHP (declaring symbols) and bootstrap of feature-rich frameworks.
More information about original PM porpouse can be found in the article: Bring High Performance Into Your PHP App (with ReactPHP)
The recommended way to install react is through composer.
{
"repositories": [
{ "type": "vcs", "url": "http://github.com/Imunhatep/rephp" },
{ "type": "vcs", "url": "http://github.com/Imunhatep/php-pm" }
],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"imunhatep/php-pm": "@dev"
}
}
./bin/ppm start --help
Usage:
start [--bridge="..."] [--port[="..."]] [--workers[="..."]] [--bootstrap[="..."]] [--app-env[="..."]] [--memory-limit[="..."]] [--memory-check-time[="..."]] [working-directory]
Arguments:
working-directory The working directory. (default: "./")
Options:
--bridge The bridge we use to convert a ReactPHP-Request to your target framework.
--host Load-Balancer host. Default is 127.0.0.1
--port Load-Balancer port. Default is 8080
--workers Worker count. Default is 8. Should be minimum equal to the number of CPU cores.
--app-env The that your application will use to bootstrap.
--bootstrap The class that will be used to bootstrap your application.
--memory-limit The memory limit for one slave process
--memory-check-time Time in seconds for checking memory limit
--help (-h) Display this help message.
--quiet (-q) Do not output any message.
--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
--version (-V) Display this application version.
--ansi Force ANSI output.
--no-ansi Disable ANSI output.
--no-interaction (-n) Do not ask any interactive question.
$ ./bin/ppm start ~/my/path/to/symfony/ --bridge=HttpKernel
{
"bootstrap": "\\PHPPM\\Bootstraps\\Symfony",
"bridge": "HttpKernel",
"appenv": "dev",
"workers": 8
}
Each worker starts its own HTTP Server which listens on port 5501, 5502, 5503 etc. Range is 5501 -> 5500+<workersCount>
.
Example config for NGiNX for 8 workers:
upstream backend {
server 127.0.0.1:5501;
server 127.0.0.1:5502;
server 127.0.0.1:5503;
server 127.0.0.1:5504;
server 127.0.0.1:5505;
server 127.0.0.1:5506;
server 127.0.0.1:5507;
server 127.0.0.1:5508;
}
server {
root /path/to/symfony/web/;
server_name servername.com;
location / {
#index index.php;
# try to serve file directly, fallback to rewrite
try_files $uri @rewriteapp;
}
location @rewriteapp {
if (!-f $request_filename) {
proxy_pass http://backend;
break;
}
}
}
This setup is slower as we can't load balance incoming connections as fast as NGiNX it does, but it's perfect for testing purposes.
##License
The code for php-pm is distributed under the terms of the GPLv3 license.