Perl extension for PHP
| From: | Johannes Schlueter | Date: | Sat, 03 May 2003 18:34:28 +0000 |
| Subject: | Perl extension for PHP | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-15811@lists.php.net to get a copy of this message | ||
Hi there,
Summary
=======
I've written a PHP Extension to embed a perl interpreter to PHP
and would like to publish it via pear/pecl.
Requirements
============
PHP 4.2.2, 4.2.3, 4.3, 4.3.1 (tested versions)
Perl 5.8.0 (due to API changes no older versions supported)
Tested using a Linux box
What can it do
==============
At the moment this is a rather simple extension, if enough
people are interested in it I can spend more time on it.
At the moment you can create an perl interpreter, let the
interpreter eval some perl code, execute a perl sub and
manipulate (read/write) scalar perl variables using a few
PHP-Extension functions.
the prototypes of thes functions look like
void perl_init(void)
Inits the perl interpreter
bool perl_eval(string source)
Parses and executes some perl code given as paramter
mixed perl_call(string name, [array param])
Calls a perl sub called name with the paramters param
Returns the perl return value if perl returns a scalar
variable, only scalar paramters in param alloud
mixed perl_get_var(string name)
Returns the value of the (scalar) parl variable name.
name needs to be in global context of the perl-script
bool perl_set_var(string name, mixed value)
Sets the perl variable name with the value value
Where required this extension does a little typecasting
between perl and PHP values. (PHP bool -> perl int, scalar
variables hold their type, other types arn't supported, yet)
Usage
=====
see included example perl.php
Problems
========
- C-written perl modules don't work (see perlembed(1) about
compiling embeded perl interpreters using perl modules
- Accessing non-existing variables or eval'ing bad perl-code
might result in segfaults
- print-calls in perl scripts while using an PHP-SPI different
from CLI or CGI are not send to the zend output stream but
somewhere
Installation:
=============
Fetch http://www.schlueters.de/perl-pre0.1.tar.bz2
extract it
to php-src/ext/ configure PHP using --with-perl=DIR were DIR
is the location of perl.h and libperl.so (on my box, both are
located at /usr/lib/perl5/5.8.0/i686-linux/CORE/). I didn't
manage compiling it using phpize, I'd be glad if someone could
help me with that.
About me
========
Just a few sentences about the guy how has to much spare time:
I'm a 21 year old student, living at Munich/Germany. I'm
using computers since I'm 14 years old, my first PHP scripts
are dated on April 25th, 2000.
Now I'd like to get some comments on this thing here and mybe
even some +1 for adding it to pear, a better documentation
is in work, but the explainations above and the example
script should help you out ;-)
johannes