# embed sapi module and multi-threading

- Thread: https://externals.io/message/43331
- Original archive: https://news-web.php.net/php.internals/43331
- Started by Bas van Beek on 2009-03-12T16:25:32+00:00
- Messages: 7
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #43331 — Bas van Beek — 2009-03-12T16:25:32+00:00

URL: https://externals.io/message/43331#43331

Hi,

For a project of mine I had to have an embedded webserver with php  
support. For this I've used the boost::asio multi-threaded example as  
a base and modified it so I could enable php scripting support.  The  
first, logical and fast thing to do was to try out the embed sapi  
module but I found it to hang on concurrent php_embed_init calls.

The biggest issue I found was that the embedded module bundles sapi  
module startup and request startup. I ended up writing my own SAPI  
module as I also needed full support for POST methods, URL queries,  
etc. but I can imagine people being interested in having an embedded  
sapi which separates module startup/shutdown and request startup/ 
shutdown so concurrency works together with being able to have  
separate request environments for each thread.

Separating these calls would allow for the following:

At program startup initialize the php environment
At each thread startup initialize a php request environment

With a few minor alterations I could convert my specific sapi module  
or current embed module to a generic embed-mt multithread capable  
module.

Would this be something that you are interested in?

kind regards,

Bas van Beek

---

## #43332 — David M. Patterson — 2009-03-12T16:49:06+00:00

URL: https://externals.io/message/43331#43332 · In reply to: #43331

I for one, would be very interested in such a module :-)
Dave

> -----Original Message-----
> From: Bas van Beek [mailto:bas@tobin.nl]
> Sent: Thursday, March 12, 2009 9:26 AM
> To: internals@lists.php.net
> Subject: [PHP-DEV] embed sapi module and multi-threading
> 
> Hi,
> 
> For a project of mine I had to have an embedded webserver with php
> support. For this I've used the boost::asio multi-threaded example as
> a base and modified it so I could enable php scripting support.  The
> first, logical and fast thing to do was to try out the embed sapi
> module but I found it to hang on concurrent php_embed_init calls.
> 
> The biggest issue I found was that the embedded module bundles sapi
> module startup and request startup. I ended up writing my own SAPI
> module as I also needed full support for POST methods, URL queries,
> etc. but I can imagine people being interested in having an embedded
> sapi which separates module startup/shutdown and request startup/
> shutdown so concurrency works together with being able to have
> separate request environments for each thread.
> 
> Separating these calls would allow for the following:
> 
> At program startup initialize the php environment
> At each thread startup initialize a php request environment
> 
> With a few minor alterations I could convert my specific sapi module
> or current embed module to a generic embed-mt multithread capable
> module.
> 
> Would this be something that you are interested in?
> 
> kind regards,
> 
> Bas van Beek

---

## #43333 — Marcus Boerger — 2009-03-12T20:04:18+00:00

URL: https://externals.io/message/43331#43333 · In reply to: #43331

Hello Bas,

 I would assume that we will see more people wanting this in the future.
So if you're willing to provide your code under PHP License, maintain it
in the foreseeable future and provide a clean version of it (as in free
from anything that is not really necessary), then you should show us a
patch. And if it looks fine you should go for an account.

marcus

Thursday, March 12, 2009, 5:25:32 PM, you wrote:

> Hi,

> For a project of mine I had to have an embedded webserver with php  
> support. For this I've used the boost::asio multi-threaded example as  
> a base and modified it so I could enable php scripting support.  The  
> first, logical and fast thing to do was to try out the embed sapi  
> module but I found it to hang on concurrent php_embed_init calls.

> The biggest issue I found was that the embedded module bundles sapi  
> module startup and request startup. I ended up writing my own SAPI  
> module as I also needed full support for POST methods, URL queries,  
> etc. but I can imagine people being interested in having an embedded  
> sapi which separates module startup/shutdown and request startup/ 
> shutdown so concurrency works together with being able to have  
> separate request environments for each thread.

> Separating these calls would allow for the following:

> At program startup initialize the php environment
> At each thread startup initialize a php request environment

> With a few minor alterations I could convert my specific sapi module  
> or current embed module to a generic embed-mt multithread capable  
> module.

> Would this be something that you are interested in?

> kind regards,

> Bas van Beek




Best regards,
 Marcus

---

## #43334 — Bas van Beek — 2009-03-12T20:26:10+00:00

URL: https://externals.io/message/43331#43334 · In reply to: #43333

No problem. I will clean up the code to remove non generic items and  
will post a link for code inspection shortly.

Bas

Op 12 mrt 2009, om 21:04 heeft Marcus Boerger het volgende geschreven:

> Hello Bas,
>
> I would assume that we will see more people wanting this in the  
> future.
> So if you're willing to provide your code under PHP License,  
> maintain it
> in the foreseeable future and provide a clean version of it (as in  
> free
> from anything that is not really necessary), then you should show us a
> patch. And if it looks fine you should go for an account.
>
> marcus
>
> Thursday, March 12, 2009, 5:25:32 PM, you wrote:
>
> > […]
>
> > […]
>
> > […]
>
> > […]
>
> > […]
>
> > […]
>
> > […]
>
> > […]
>
> > […]
>
>
>
>
> Best regards,
> Marcus

---

## #43427 — Bas van Beek — 2009-03-21T17:00:38+00:00

URL: https://externals.io/message/43331#43427 · In reply to: #43333

Hi PHP Devs,

I've placed an example of the Embed2 SAPI in a subversion repository:

	http://svn.tobin.nl/public/php/embed2/trunk/	

I hope you like it...

kind regards,

Bas van Beek

Op 12 mrt 2009, om 21:04 heeft Marcus Boerger het volgende geschreven:

> Hello Bas,
>
> I would assume that we will see more people wanting this in the  
> future.
> So if you're willing to provide your code under PHP License,  
> maintain it
> in the foreseeable future and provide a clean version of it (as in  
> free
> from anything that is not really necessary), then you should show us a
> patch. And if it looks fine you should go for an account.
>
> marcus
>
> Thursday, March 12, 2009, 5:25:32 PM, you wrote:
>
> > […]
>
> > […]
>
> > […]
>
> > […]
>
> > […]
>
> > […]
>
> > […]
>
> > […]
>
> > […]
>
>
>
>
> Best regards,
> Marcus

---

## #43428 — Cesar D. Rodas — 2009-03-21T21:18:02+00:00

URL: https://externals.io/message/43331#43428 · In reply to: #43427

I have some problem on the configure script, any ideas? this is the ouput


creating libtool
appending configuration tag "CXX" to libtool
shtool:mkdir:Error: invalid number of arguments (at least 1 expected)
shtool:mkdir:Hint:  run `./build/shtool mkdir -h' or `man shtool' for details
configure: creating ./config.status
config.status: creating config.h
config.status: config.h is unchanged


2009/3/21 Bas van Beek <bas@tobin.nl>:
> Hi PHP Devs,
>
> I've placed an example of the Embed2 SAPI in a subversion repository:
>
>        http://svn.tobin.nl/public/php/embed2/trunk/
>
> I hope you like it...
>
> kind regards,
>
> Bas van Beek
>
> Op 12 mrt 2009, om 21:04 heeft Marcus Boerger het volgende geschreven:
>
> > […]
>
>
> --
> 
> 
>
>



-- 
Cesar D. Rodas
http://cesar.la/
Phone: +595-961-974165
Robert Benchley  - "I have tried to know absolutely nothing about a
great many things, and I have succeeded fair...

---

## #69819 — Simon Fogliato — 2013-10-23T21:17:34+00:00

URL: https://externals.io/message/43331#69819 · In reply to: #43331

You write "I also needed full support for POST methods"...

How did you end up handling $_POST["..."], $_GET["..."], etc? Request headers 
& form inputs are not being passed or setup to be accessed in PHP.

Did you ever post your handler code to setup PHP's environment variables to 
process user input forms?

Any info would be appreciated, your embed2 lib rocks!
