http://docs.akbkhome.com/php_embed.c.txt
http://docs.akbkhome.com/php_embed.h.txt
replace the code in php_embed with them, make sure you compile with the zts enabled, and the macros's are similar to the original embed (use threaded start call at application start up, and thread start /start end within the pthread_start(...callback..) method
check out php.pecl on #efnet you might get lucky.. Regards Alan
Bob Beaty wrote:
All,
I've searched the web for this answer and I'm stumped. I can't find the answers. So I thought I'd try the lists. Here goes:
I have seen how to embed PHP 5 using the code like:
... php_embed_module.ub_write = my_ub_write_func; php_embed_module.log_message = my_log_func; php_embed_module.sapi_error = my_error_log; ... zend_eval_string(...); ...
And from this, I looked in the code to see that php_embed_module is a static variable that's used in the initialization methods so it *seems* as though this can't possibly be thread-safe.
Yet web servers do it all the time.
I read on the web that the global variables for the PHP engine are maintained in the thread where they were originally defined. This leads me to believe that there's the possibility that the php_embed_module and other important variables might be thread-local storage, and therefore thread-safe.
Yet if that were the case, how does one define different write, log, and error functions so that the engine of one thread does not interfere with another?
In general, my problem is this:
I have a multi-threaded C++ app that I want to embed the PHP 5 engine into. I have read up how to create extensions to PHP, and will do that as necessary, but I need to be able to call this engine from my code and capture stdout, stderr, etc.
Can I do this with PHP 5.0.3 as it exists now?
Are there special things I need to watch out for?
Any pointers, FAQ sites, etc. that I can look at would be most helpful.
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php