You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Geoffrey Young <ge...@modperlcookbook.org> on 2005/11/22 16:55:21 UTC

Re: postprocessing html+php code generated by a mod_perl system before to send it to browser


Edgard Pineda wrote:
> Hello,
> 	I need some hints on this problem: I have a code in mod_perl that
> generate a html page with some php code (<?php ... ?>), but before to
> send this data to the browser I would like the mod_php processed the
> code first. How can I accomplish this? (I use mod_perl 1.26, Apache 1.3,
> php 4.1) (are there some functions on Apache module?)

the short answer is that you can't do this with apache 1.3.

if you upgrade to apache 2.0 or higher you can do this with recent versions
of php.  a cursory glance through the php code and configuration leads me to
believe that php will function as a filter if you build php like this

  $ ./configure --with-apxs2filter=/path/to/apache/bin/apxs

but I'm not really into php, so it might take more than that.  but it looks
like php definitely has a filter option in at least 5.0.5 (and most likely
earlier).  folks on the various php help lists should know more.

HTH

--Geoff

Re: postprocessing html+php code generated by a mod_perl system before to send it to browser

Posted by Clint Edwards <ce...@mcclatchyinteractive.com>.
I agree with Geoff, upgrading is the cleanest way around this problem.
However, that solution was not immediately possible for me and I am in a
similar situation.  I have an Apache Handler that generates HTML pages
with embedded PHP.  I wrote another Apache Handler to process the output
from the first Handler.  In the second handler I use the perl module PHP
(http://search.cpan.org/~karasik/PHP-0.09/PHP.pm) to do the heavy
lifting for me.  You may not use an Apache Handler to do this, but you
can still use the PHP module to process your PHP.  Again this is a bit
hackish, but still a workaround.

Another possible solution is to write your HTML file to your docroot,
and redirect the user to the HTML page on the docroot.

Clint

On Tue, 2005-11-22 at 10:55 -0500, Geoffrey Young wrote:
> 
> Edgard Pineda wrote:
> > Hello,
> > 	I need some hints on this problem: I have a code in mod_perl that
> > generate a html page with some php code (<?php ... ?>), but before to
> > send this data to the browser I would like the mod_php processed the
> > code first. How can I accomplish this? (I use mod_perl 1.26, Apache 1.3,
> > php 4.1) (are there some functions on Apache module?)
> 
> the short answer is that you can't do this with apache 1.3.
> 
> if you upgrade to apache 2.0 or higher you can do this with recent versions
> of php.  a cursory glance through the php code and configuration leads me to
> believe that php will function as a filter if you build php like this
> 
>   $ ./configure --with-apxs2filter=/path/to/apache/bin/apxs
> 
> but I'm not really into php, so it might take more than that.  but it looks
> like php definitely has a filter option in at least 5.0.5 (and most likely
> earlier).  folks on the various php help lists should know more.
> 
> HTH
> 
> --Geoff
-- 
Clint Edwards
Software Developer
McClatchy Interactive
919.861.1265
cedwards@mcclatchyinteractive.com
http://www.mcclatchyinteractive.com