[PATCH] Repost - Adding Output Filters w/ Apache2 Handler SAPI

php.internals

Paul Querna

22 years ago
I added two new functions for handling output filters in the Apache2Handler SAPI: bool apache_add_output_filter(string filter_name) - Attempts to add the named filter to the Filter Chain. array apache_get_output_filters() - Returns an array of all Active Output filters for this request The ability to add an output filter is very helpful in the apache 2model. For example with this I was able to add an XSLT output filter that I use in other areas to render XML generated from PHP to HTML. The attached patches are for both PHP4 CVS and PHP5 CVS. They are also online at: http://force-elite.com/~chip/patches/php-src/apache2-filters/ I posted this patches last Monday, but received 0 replies. Are the patches acceptable, is there anything to change, or are there any comments? Thanks, -Paul Querna

Andi Gutmans

22 years ago
Can you please give an example on how this can be used? At 08:13 PM 4/25/2004 -0600, Paul Querna wrote:

Paul Querna

22 years ago
On Mon, 2004-04-26 at 02:33, Andi Gutmans wrote:
> Can you please give an example on how this can be used?
Attached is a simple example of using both add_output_filter and get_output_filters. -Paul Querna

Andi Gutmans

22 years ago
So what does the apache_add_output_filter("XSLT") do? It adds a filter to the current request which runs after PHP? Andi At 12:21 PM 4/26/2004 -0600, Paul Querna wrote:

Paul Querna

22 years ago
On Tue, 2004-04-27 at 08:48, Andi Gutmans wrote:
> So what does the apache_add_output_filter("XSLT") do? It adds a filter to > the current request which runs after PHP? >
Correct. First it tries to find an output filter registered as "XSLT". If there is not a filter that has registered the name "XSLT", it returns false. If there is a filter with that name, It adds it onto the Apache 2 Output filter chain and returns true. This is also how things like gzip compression happen with apache 2. For example, adding apache_add_output_filter("DEFLATE") would force mod_deflate to compress the output from PHP. (make sure this is done after adding XSLT, Ordering is important! The XSLT filter does not understand compressed content.) http://httpd.apache.org/docs-2.0/filter.html Provides some more information on filters in Apache 2. - Paul Querna

Edward Rudd

22 years ago
Woohoo! This is an awesome patch.. I hope it gets accepted into PHP proper. On Mon, 26 Apr 2004 11:33:48 +0300, Andi Gutmans wrote:
> Can you please give an example on how this can be used? >
I am using it in a PHP web app I am writing where I am generating XML output and running it through an XML filter via XSLT (mod_transform). And I can then selectively turn the filter on and off.. IE for XML data that I don't want transformed, or for non-xml data.

Jevon Wright

22 years ago
What if you extended this to cover PHP in general - you could make your PHP always generate XML data and then with add_output_filter(proprietary string or callback function) you could make PHP transform the output at the end of the script execution (possibly multiple times). I know a lot of developers which are interested in a script -> xml -> xml -> xml -> xhtml pipeline, and something like add_output_filter() might be a godsend :) Yeah, I know it can be done in userland (somewhat)... Jevon ----- Original Message ----- From: "Edward Rudd" <eddie@omegaware.com> To: <internals@lists.php.net> Sent: Friday, April 30, 2004 1:31 PM Subject: Re: [PHP-DEV] [PATCH] Repost - Adding Output Filters w/ Apache2 Handler SAPI