Forum OpenACS Development: Re: Tcl calls from PHP?

Collapse
8: Re: Tcl calls from PHP? (response to 1)
Posted by Dossy Shiobara on
This has inspired me to hack this capability into PHP.  I currently have a patch against PHP 4.3.7RC1 that defines a new PHP function "tcl_eval".  To se it in action, see:

http://panoptic.com/test2.php

I'll bang on it some more, and then try implementing this against the latest stable release of PHP, then make a patch available.

-- Dossy

Collapse
9: Re: Tcl calls from PHP? (response to 8)
Posted by Malte Sussdorff on
How easy is it the other way round, creating an ns_php function? This would e.g. allow us to log in the user into Squirrelmail or other PHP packages by calling the PHP function that logs the user in and sets the cookie.
Collapse
10: Re: Tcl calls from PHP? (response to 9)
Posted by Dossy Shiobara on
I hesitantly say that the code change is "easy" however, performance will be absolutely miserable.

Unlike Tcl and its interpreted script model where a Tcl interp can be fed a Tcl script for evaluation, PHP is more like a stand-alone executable which executes a whole PHP script, like a Unix shell.  It creates separate processes as necessary for script processing, and the PHP (Zend) engine is file-based.

Because of this, every call to the proposed "ns_php" command would fork the nsd process and start up a brand new PHP execution process.  There would be no cohesion between two calls to ns_php, e.g., setting variables in one won't be visible in the next.

There's a highly experimental "embed" SAPI (server API) module for PHP, but after reviewing the code, it doesn't address the issues I've already mentioned.

In short, there's very little practical value in implementing a ns_php-like command for Tcl the way PHP is implemented today.  And, given the design of PHP, I don't expect to see a PHP version that could be embedded considering how deeply rooted these design issues are.  Perhaps, it'd be possible to lift the Zend engine and make it a proper embeddable script interpreter, but even with the new Zend 2.0 engine, they haven't gone in that direction.

For now, just be happy to be able to get back to the Tcl interp. from a PHP page -- that alone will make the AOLserver/PHP combo very powerful.

-- Dossy