PHParser 1.1.5 Release Information
PHParser - A Gateway to PHP!
PHParser gives you the chance to reuse your old PHP-scripts from the days before you experienced ZOPE and Python. PHParser tries to be a clean and stable product for production environments. Nevertheless you should use PHParser with care! PHP is a mighty language!! Take all precautions (e.g. edit php.ini in order to disable system-critial functions from PHP) to avoid trouble on your server!!! Never give untrusted users the right to add PHParsers in your ZOPE-installation!!!! Learn PYTHON and forget PHP!!!!!
PHParser is a ZOPE-Product which is based heavily on the DTML-Document-Class. A PHParser will give you all the features of a DTML-Document + all the features of PHP. This means that you can mix DTML into your PHP-Code.
PHParser is a real subclass of the DTML-Document-class. So you can use Cache-Managers, FTP, WebDav and so on a PHParser. To state it clearly: PHParser only modifies the __caller__-function from the DTML-Document-class, the rest is acquired from the DTML-Document-class.
PHParser works as a postprocessor: After rendering all DTML-tags in your document, PHParser will pipe the result through an external PHP-Interpreter.
PHParser emulates the pure PHP environment. This is done by rewriting PHP global variables, including $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS, and etc in 0.9.0. PHParser 1.0.0 does not rewrite most of those variables. Instead, it passes them in the environment and excutes PHP CGI interpreter like what Apache does.
Most stand-alone scripts will work without changes. But for scripts using include/require functions, please refer to How to make include/require functions work in PHParser.
PHPGateway object comes with PHParser 1.0.0. It can be used to run a set of PHP scripts stored in a directory in the file system. So many pure PHP applications can be running on Zope sometimes without the need of modifying a single byte of their source codes!
The header and body of the returned result will be decoded, so
you can use PHP-'Header'-functions. This is useful for redirects
{Header(Location: http://www.zope.org/
)} and the creation of images:
<?php Header( "Content-type: image/png"); $image = imagecreate(100,16); $white = ImageColorAllocate($image,255,255,255); $grey = ImageColorAllocate($image,50,50,50); ImageString($image,3,0,0,"powered by PHP",$grey); ImagePNG($image); ImageDestroy($image); ?>
The php codes are interpreted by the "php" execution file. If users have build PHP as an Apache Module, this file doesn't exist. In other words: You have to compile/install PHP as CGI and tell PHParser where in the file system it is located.
Please send an email to Wei He if you like this product or have any comments/questions/proposals about it.