event driven PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Csaba Gabor

    event driven PHP

    Maybe someone has an idea about this... I have two PHP scripts and
    they would like to efficiently communicate (on a a callback or event
    driven basis) with each other. If these are CLI versions of PHP, this
    is not so bad because I can have the communication go across a hidden
    instance of IE by means of events on IE.

    But if one of the PHP instances is invoked via a server (Apache 2),
    then the security restrictions become fairly severe. Specifically,
    though I can create instances of IE ($ie = new
    COM("InternetEx plorer.Applicat ion")), the CLI versions of PHP cannot
    see the 'server instances' of IE and the server PHP's cannot even query
    for instances of IE (using the Windows collection of the
    Shell.Applicati on COM object). Thus, I cannot hook up the two
    instances of PHP.


    I thought of other possibilities. Each is essentially a way to
    transfer data. I can either use VOLATILE environment variables (for
    small amounts of data), or I can use http://php.net/shmop or writing
    files (but I hate writing files) for larger amounts of data. All these
    suffer from the same problem, however. Near as I can tell, there is
    nothing to let the 'listening' side know that data has changed. It has
    to keep running a loop, and checking for any possible change in data.
    Of course the sending side could specify where the change has happened,
    but this still requires the receiving side to be running a loop.

    So my question is whether anyone has had a happy approach to the issue
    of event driven programming in php? Another way to ask this is whether
    php has callback functions that can be remotely triggered by
    cooperating programs (e.g. the __destruct of classes is near to this -
    it's effectively a callback that responds to an event: the destruction
    of a class instance)

    Thanks,
    Csaba Gabor from Vienna.

  • Chung Leong

    #2
    Re: event driven PHP

    Have the server script listen on a port and the client script connect
    to it using the socket functions.

    Comment

    Working...