imcsk8 has asked for the wisdom of the Perl Monks concerning the following question:

hello, i'm writing a apache module with mod_perl and i want to use php programs from wihtin this module. i would like to know if this is possible, i have the notion that mod_perl can use other apache modules but i'm not sure if this can be done. thanks
ignorance, the plague is everywhere --guttermouth

Replies are listed 'Best First'.
Re: use php objects from within mod_perl
by cees (Curate) on Nov 29, 2003 at 02:22 UTC

    You have got a couple of options, but none of them are good!

    1. you can get perl to execute a PHP script using the standalone CGI version of PHP and do something with the results that it generates (this will only allow you to parse and alter the output of the PHP program, it won't actually let you call a PHP function).
    2. You can use Apache2 and mod_perl2 which allow you to write a mod_perl Filter that can filter the output of mod_php (again, it is only working on the output generated by PHP)
    3. A quick search on CPAN for PHP found PHP::Include. This module claims to be able to parse very simple PHP, and convert it to perl code. So depending on how complex your PHP is, it might be an option.
    4. Convince someone to write Inline::PHP... Good luck with that one, since I don't think there would be much demand for that.

Without knowing how extensive the code is that you would like to run, my recommendation would be to rewrite your PHP in perl. PHP doesn't do anything that perl can't do...

- Cees

      thanks for your response, i can't rewrite everything in perl because the idea is that the module should be able to use code in both languages, but i think that the mod_perl filter can be the solution.
      thanks

      ignorance, the plague is everywhere
      --guttermouth