I need to extend a PHP application with some Erlang-based server functionality. More specifically, the Erlang app's role is to provide some services for which non-trivial state must be maintained, and which will be queried by an AJAX client periodically (the client is currently being written using PHP as the "primary" backend - there is a chance that YAWS could be accepted as the server for that part, but probably not at this time).
So, my question is this: how should one perform such integration? The methods I've basically come up with are:
1) Open a socket from a PHP script and query the Erlang backend using a proprietary protocol (the queries are simple, but might return a couple KB). Is JSON generally more convenient for relatively flat datastructures?
3) As (1) but extend the PHP interpreter so it opens a persistent connection. Does anyone know how hard this might be? AFAIK Apache threads are mapped to PHP threads, which "share nothing". Is this correct?
4) Somehow get Management to agree on moving the entire AJAX bit to YAWS (unlikely). In this case, I would open a separate socket for YAWS.