Re: [svn:PHP-Sandwich] rev 1422 - PHP-Sandwich/trunk/lib/PHP

[email protected] (David Wheeler) Fri, 29 Jul 2005 16:01:51 -0700
Newsgroups perl.php.sandwich.dev
Message-ID <[email protected]>
On Jul 29, 2005, at 2:41 PM, [email protected] wrote:

> initial perl docs

Cool! One other thing it needs: The README should be updated to  
describe what special switches need to be used during the compilation  
of PHP5.

> +=head1 DESCRIPTION
> +
> +This class encapsulates an embedded PHP5 intepreter.  It provides
> +proxy methods (via AUTOLOAD) to all the functions declared in the
> +PHP interpreter, transparent conversion of Perl datatypes to PHP
> +(and vice-versa), and the ability for PHP to similarly call Perl
> +subroutines and access the Perl symbol table.
> +
> +The goal of this package is to construct a transaparent bridge for
> +running PHP code and Perl code side-by-side.

I've been meaning to ask...Oh, hell, I'll just try it...I wanted to  
know if I can call class methods (such as constructors) on Perl  
classes from PHP. This example doesn't work, but maybe I'm doing  
something wrong?

#!/usr/bin/perl -w

use strict;
use PHP::Interpreter;
use DBI;

my $php = PHP::Interpreter->new;
$php->eval(q/
     $dbh = DBI->connect("dbi:SQLite:dbname=dbfile", "", "");
     $dbh->do('CREATE TABLE foo (bar text)');
     $dbh->do("INSERT INTO foo ('This is a test')");
     $sel = $dbh->prepare('SELECT bar FROM foo');
     $sel->execute;
     foreach ($sel->fetch as $val) {
         echo "$val\n";
     }
     $dbh->disconnect;
/);



> +=head2 Public Class Methods

Actually, I think these are instance methods...um, I'll do a bit of  
neatening with the POD in a sec.

> +=item $php->include("somePhpFile.php");

Is this an AUTOLOAD method, by chance?

> +=head3 set_output_hander()

Could there perhaps also be a method to modify the other parameters  
to new? Maybe set_global()?

   $php->set_global(COOKIE => {foo => 'bar'});

> +=head3 get_output()


> +=head3 clear_output()

Ooh, nice, I wasn't aware of these methods.


> +=head3 instantiate()
> +
> +=over
> +
> +=item my $instance = $php->instantiate('stdClass', @args);
> +
> +
> +Create and return an instance of the specified PHP class.  Any  
> additional args are passed to the object''s constructor.

Nice, PHP OO support built-in. Thanks!

Great work, George. The Bricolage PHP burner is working great. Thanks!

Best,

David