Re: Passing data into the PHP Bric Burner

[email protected] (David Wheeler) Tue, 24 May 2005 14:18:24 -0700
Newsgroups perl.php.sandwich.dev
Message-ID <[email protected]>
On May 24, 2005, at 07:05 , George Schlossnagle wrote:

> You can do that now - see the test cases for examples of passing  
> complex types between PHP and Perl.

Great, thanks!

> The question, in a bit more detail, is this:  what is to be the  
> standard way that PHP will be first called from Perl in burn_one 
> ().  To me, this feels right:
>
>
> $perl->include($file, $arghash);
>
> And that under the hood this is equivalent to doing this in PHP:
>
> <?php
> include($file);
> ?>

That seems reasonable, although I assume that you meant $php->include 
(), yes?

> In PHP, include doesn't support the passing of parameters.  The way  
> that PHP scripts get data passed from the outside world is that  
> request data (query params, post data, cookies, etc.) are populated  
> in so-called autoglobals ($_GET, $_POST, and $_COOKIE, etc.).  Due  
> to scoping semantics, these are tied to the active interpreter  
> request and not to the current include being processed.

Ick.

> What I think should happen is this:  the PHP::Interpreter method  
> should work like one of these two ways:
>
>
> $php = PHP::Interpreter->new({ GET => { ... }, POST => { ... },  
> COOKIE => { ... }, BRIC => { ... });
> $php->include($file);
>
> This lets you set the usual autoglobals that are available inside  
> PHP, plus adds a new one $_BRIC, which acknowledges that the data  
> passed in for this template is 'special'.

Well, that makes sense, except for the $_BRIC part. I don't think  
that PHP Sandwich should have any specific Bricolage interface/code.  
Why wouldn't I just set up the Bricolage-specific stuff (objects) via  
the method you've pointed me to in the first paragraph of your email?

> The other option is to do this:
>
>
> $php = PHP::Interpreter->new({ GET => { ... }, POST => { ... },  
> COOKIE => { ... });
> $php->include($file, BRIC => { ... });

That's less like how PHP itself works, though, yes?

> In this case, there are two things that can happen:
>
> 1) BRIC replaces the old BRIC
> 2) BRIC is merged into the old BRIC
> 3) We do some sort of artificial scope limiting, which would be  
> really un-PHPish and bad, so I only bring it up to note that it was  
> considered and turned down.

Okay.

Regards,

David