PHPApp


Methods

f __init__(self, base_dir, php_script='php-cgi', php_ini='/home/ianb/src/wphp/wphp/default-php.ini', php_options=None, fcgi_port=None, search_fcgi_port_starting=10000, logger='wphp') ...

Create a WSGI wrapper around a PHP application.

base_dir is the root of the PHP application. This contains .php files, and potentially other static files. (@@: Currently there is no way to indicate files that should not be served, like .inc files or certain directories)

php_script is the path to the php-cgi script you want to use. By default it just looks on the $PATH for that file.

php_ini is the path to the php.ini file you want to use. An example (taken from the default PHP file) is in wphp/default-php.ini. This allows you to customize the language environment that the PHP files run in.

php_options is a dictionary of config-name: value, of specific overrides for PHP options. For instance, {'magic_quotes_gpc': 'Off'} will turn off magic quotes.

PHP is started as a long-running FastCGI process. PHP (from what I can tell) only supports listening over IP sockets, so we must get a port for it. You may provide a specific port (with fcgi_port ) or give a starting port number (default 10000), and the first free port will be used.

f __call__(self, environ, start_response) ...

f find_script(self, base, path) ...

Given a path, finds the file the path points to, and the extra portion of the path (PATH_INFO).

f create_child(self) ...

Creates the PHP subprocess, with some locking and whatnot, and creates the WSGI application wrapper around that.

f spawn_php(self, port) ...

Creates a PHP process that listens for FastCGI requests on the given port.

f find_port(self) ...

Finds a free port.

f close(self) ...

Kills the PHP subprocess. Registered with atexit, so the subprocess is killed when this process dies.

See the source for more information.