in reply to Using Perl & PHP together

The question is: can Perl and PHP co-exist in harmony on one website in order to exploit the best of both?

So what's the best of both?

For PHP it's probably the execution model (when running as an Apache module) - no persistent globals, hard to knock down (other than a general Apache DOS) etc.

Ease of programming isn't really an argument - when you do a default;

echo "<p>".$someValueSubmittedByUser."</p>";

...you may be subjecting yourself to XSS - need htmlspecialchars(). Most PHP developers are themselves using template engines like Smarty which default to stuff like escaping entities.

But think the execution model is a valid reason to have PHP being the next thing, after Apache, to handle requests.

For Perl it's for solving the hard problems (e.g. searching, Unicode normalization etc.), everything CPAN and that it's a more powerful programming language.

So it's a question of integration, for which you might consider one of...

PHP::Interpreter - embedded PHP interpreter (if you control your own servers)

Fuse, Fuse::Simple, Fuse::DBI - have been playing a little here - Fuse filesystem implemented in Perl, PHP talking via standard file system calls. Think there's potential, but not sure if you can do robust stuff this way. Also the main Perl Fuse module wants the latest greatest fuse, which doesn't seem to be packaged by many distros at the moment. Again need control over your servers.

Call Perl as a remote daemon or shell out - slow but probably easiest (and you're only choice on a shared host). If your Perl search engine can spit out XML, PHP5's libxml2 stuff (e.g. XSLT) would be pretty effecient. There's also a couple of Perl modules able to read / produce PHP's serialized string format - php-serialization and serialize

Replies are listed 'Best First'.
Re^2: Using Perl & PHP together
by harryf (Beadle) on Aug 30, 2006 at 15:02 UTC
    One further thought - if you're using plucene, there's a PHP implementation now available in the Zend framework described here. I believe they've aim for compatibility with Java Lucene so perhaps it would also work with plucene i.e. you generate the indices with plucene but use the PHP implementation to search them.