I have been thinking about how to run PHP on top of Web2Py. I'm interested 
in doing this because I want to augment an existing PHP app via Web2Py (For 
example, use the T() internationalization object; use Web2Py's auth access 
control). Also it will be easier to port a PHP application to Web2Py one 
piece at a time if the rest of the unported application can run as PHP.

Something similar was done with 
Django<http://code.djangoproject.com/ticket/2440>: the 
PHP-based PmWiki <http://www.pmwiki.org/wiki/Main/WikiSandbox?action=edit> and 
even WordPress were integrated with 
Django<http://showmedo.com/videotutorials/video?name=pythonNapleonePyConTech2&fromSeriesID=54>.
 
I've been studying the Python source 
code<http://code.djangoproject.com/attachment/ticket/2440/php.py>, 
and it looks like this could be used to render PHP from a Web2Py view. I'm 
trying to imagine how this would fit into Web2Py; perhaps distributed as a 
plugin:

   1. The PHP code should not be aware it is running on top of Web2Py. Any 
   Web2Py template language is expanded before being sent to the PHP parser. (I 
   just watched the video, and it provides some more details. It looks like the 
   PHP files had to be modified a bit, which I was trying to avoid, if 
   possible.)
   2. The PHP files (possibly with some {{Web2Py template code}} added) seem 
   like views, but a PHP application will not have any associated Web2Py 
   actions. Should there be a Web2Py controller that manages requests for PHP 
   content, picking the correct PHP file based on the request? Should the PHP 
   files just reside in a new, special php directory?
   3. How are POST, GET, and SESSION variables passed to/from PHP? It seems 
   PHP sessions are stored on the server; not sure about POST and GET... PmWiki 
   uses URL variables, so I think they are being passed somehow.

Any insights from people more familiar with Web2Py, PHP, and/or Django much 
appreciated!

John

Reply via email to