How to serve php from within Zope
Hi, I'm using Apache to serve my Zope pages. I want to serve up some PHP scripts as part of a page wrapped with Zope methods. How do I serve the contents in the /some/other/directory/for/PHP/scripts from within Zope? For example, I want to call index.php3 from within the index_html of a Zope folder and have the contents included in the place I make the call. Andres Corrada
Andres Corrada-Emmanuel wrote:
Hi, I'm using Apache to serve my Zope pages. I want to serve up some PHP scripts as part of a page wrapped with Zope methods. How do I serve the contents in the /some/other/directory/for/PHP/scripts from within Zope? For example, I want to call index.php3 from within the index_html of a Zope folder and have the contents included in the place I make the call.
Zope doesn't know how to call or execute php code. To do this, you need to have Zope make an 'external' http call back out to Apache, which will execute the php code, return it to Zope, which returns it to your client. Here is a good how-to on it: http://www.zope.org/Members/lstaffor/ZClientMethod -Michel
Thus spake Michel Pelletier (michel@digicool.com):
Andres Corrada-Emmanuel wrote:
Hi, I'm using Apache to serve my Zope pages. I want to serve up some PHP scripts as part of a page wrapped with Zope methods. How do I serve the contents in the /some/other/directory/for/PHP/scripts from within Zope? For example, I want to call index.php3 from within the index_html of a Zope folder and have the contents included in the place I make the call.
Zope doesn't know how to call or execute php code. To do this, you need to have Zope make an 'external' http call back out to Apache, which will execute the php code, return it to Zope, which returns it to your client.
Here is a good how-to on it:
http://www.zope.org/Members/lstaffor/ZClientMethod
-Michel
Actuatly, there may be one other quicker method to do this. You can somehow (i haven't tried this) compile php into a stand alown executable. Then you could then have an external method do a shell call running the php script. Another interesting thing you could do would be to make a zope product that stored php3 code, and then called out to php to parse it. This might not be a bad way to allow clients to have their own maintainable php3 scripts up on the web without giving them ftp or shell access. hmm.. sRp -- Scott Parish http://srparish.net
Scott Parish wrote:
Actuatly, there may be one other quicker method to do this. You can somehow (i haven't tried this) compile php into a stand alown executable. Then you could then have an external method do a shell call running the php script. Another interesting thing you could do would be to make a zope product that stored php3 code, and then called out to php to parse it. This might not be a bad way to allow clients to have their own maintainable php3 scripts up on the web without giving them ftp or shell access. hmm..
Or even better, a generalized version - so you could serve perl and php and python cgi scripts transparently from zope. That's be pretty cool actually - migrating our old sites from php to Zope would be trivial. Of course, it'd be much slower than having PHP3 compiled in to Apache. -- Itamar S.T. itamars@ibm.net
Why not use something like SWIG (I don't know much about it, just a general idea on what it does), to link the interpreter to python, and then make a Zope extension like <dtml-perl xxx> to call it? Then you could probably get the perl/PHP scripts into the ZODB, and therefore get cached, making it even faster.. --John Sutherland
-----Original Message----- From: itamar@localhost.localdomain [mailto:itamar@localhost.localdomain]On Behalf Of Itamar Shtull-Trauring Sent: Thursday, March 23, 2000 12:48 PM To: Scott Parish Cc: zope@zope.org Subject: Re: [Zope] How to serve php from within Zope
Scott Parish wrote:
Actuatly, there may be one other quicker method to do this. You can somehow (i haven't tried this) compile php into a stand alown executable. Then you could then have an external method do a shell call running the php script. Another interesting thing you could do would be to make a zope product that stored php3 code, and then called out to php to parse it. This might not be a bad way to allow clients to have their own maintainable php3 scripts up on the web without giving them ftp or shell access. hmm..
Or even better, a generalized version - so you could serve perl and php and python cgi scripts transparently from zope. That's be pretty cool actually - migrating our old sites from php to Zope would be trivial.
Of course, it'd be much slower than having PHP3 compiled in to Apache.
-- Itamar S.T. itamars@ibm.net
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Scott Parish wrote:
Actuatly, there may be one other quicker method to do this. You can somehow (i haven't tried this) compile php into a stand alown executable. Then you could then have an external method do a shell call running the php script. Another interesting thing you could do would be to make a zope product that stored php3 code, and then called out to php to parse it. This might not be a bad way to allow clients to have their own maintainable php3 scripts up on the web without giving them ftp or shell access. hmm..
sRp
-- Scott Parish http://srparish.net
I've implemented a variant of Michel's suggestion. Let me explain what I am trying to do. I'm trying to implement the SelfServeFAQ:www.lcg.org/ssfaq (SSF),written in php3, within my Zope website. To give a consistent look to my site, I also want to wrap the SSF with standard_html_header, etc. So when a visitor goes to www.mysite.com/FAQ they are really being served /SSF/directory/index.php3 wrapped with my Zope code. The problems come when a user clicks on www.mysite.com/FAQ/add.php3 or some such similar link in the HTML produced by index.php3. I tried using mod_rewrite in Apache, but found that Zope used www.mysite.com/FAQ/add.php3 as the base for all the links in the wrapping code. The only way I found to avoid this was to use the "[R]" flag in the Apache RewriteRule. But I want SSF to be transparent to the user so instead I used SiteAccess to rewrite /FAQ/add.php3 to /FAQ and pass /FAQ/index_html the script name "add.php3". index_html then uses lstaffor's How-To tip( use "Client.call( www.mysite.com/SSF/directory/add.php3)[ 1 ]" ) to embed the PHP script call in my Zope page. In addition, I wrote additional code in my accessRule to pass images in the PHP directory tree via Zope. There is one inconveniences with this approach: I had to hack SSF to remove the <html> tags and some others returned by Client.call (it worked otherwise but, hey, I want my HTML code to be clean). But all in all, the resources of Zope (the code and the community around it) allowed me to solve the problem with very little modification of the SSF PHP directory tree contents. If there is wider interest on this I could write a How-To on it. Andres Corrada
participants (6)
-
Andres Corrada -
Andres Corrada-Emmanuel -
Itamar Shtull-Trauring -
John Sutherland -
Michel Pelletier -
Scott Parish