You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Manfred Rebentisch <mr...@comparat.de> on 2006/12/01 17:54:10 UTC
Call PHP from my module?
Hello,
I use an own apache 2 module (not filter, it is a handler!), written in C,
using apr. The module handler works on a VHost and generates dynamic HTML
with database content.
It works fine and I want to enhance the code for using embedded PHP.
If I do the final parsing, writing the bucket brigades, I want to handle
embedded PHP-Code ( between <?php ... ?> ). Can someone give me a tip, how to
call PHP at this point?
At the moment I call ap_pass_brigade(apReq->output_filters, bb); where 'bb' is
the bucket brigade, return OK back to apache.
The I do install with
ap_hook_handler (cp_handler, NULL, NULL, APR_HOOK_FIRST);
or
ap_hook_handler (cp_handler, NULL, NULL, APR_HOOK_MIDDLE);
or
ap_hook_handler (cp_handler, NULL, NULL, APR_HOOK_LAST);
or
static const char * const successors[] = { "mod_php5.c", NULL };
ap_hook_handler (cp_handler, NULL, successors, APR_HOOK_FIRST);
with no difference.
Thank you in advance
Manfred
Re: Call PHP from my module?
Posted by Joe Lewis <jo...@joe-lewis.com>.
Manfred Rebentisch wrote:
> It works fine and I want to enhance the code for using embedded PHP.
>
[snip]
> At the moment I call ap_pass_brigade(apReq->output_filters, bb); where 'bb' is
> the bucket brigade, return OK back to apache.
> The I do install with
> ap_hook_handler (cp_handler, NULL, NULL, APR_HOOK_FIRST);
> or
> ap_hook_handler (cp_handler, NULL, NULL, APR_HOOK_MIDDLE);
> or
> ap_hook_handler (cp_handler, NULL, NULL, APR_HOOK_LAST);
> or
> static const char * const successors[] = { "mod_php5.c", NULL };
> ap_hook_handler (cp_handler, NULL, successors, APR_HOOK_FIRST);
>
> with no difference.
>
You may have to change the content type to application/x-httpd-php . PHP
won't parse it without it. I can't remember off of the top of my head
whether successors is the 2nd param or the third - just ensure that php
is running AFTER yours, and you should be fine.
Joe