CLI Web Server customization
| From: | Kevin Ingwersen | Date: | Wed, 06 Nov 2013 01:06:31 +0000 |
| Subject: | CLI Web Server customization | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-70023@lists.php.net to get a copy of this message | ||
Hello everyone.
Currently, I am working on a project that allows PHP applications to be developed with a GUI
frontend based on Chromium - and later on CEF. For this to work properly, I am spawning a new
Chromium process with some command line switches to allow customization of the launch. This means, I
can pass in the URL which should be opened, and disable features such as translation and alike.
However, the problem is the HTTP backend. Currently, I am using a PHP script in the same process as
the "watching" process - which is basically a while loop that awaits for a client
connection. By using the pthreads extension, I am also handling events that are received by the
Remote Debug Protocol via a WebSocket connection (PHP acting as a client here). As you can see, this
is a little chaos. So I have the event listener, the Webserver and process watcher for Chromium in
seperated threads. Once the browser is quit, I have to use posix_kill to make sure the webserver
dies as well - because it simply wouldn't.
So I got to the conclusion that I may change the logic, and remove the webserver, and replace it by
another spawned process of the PHP CLI HTTP server. The problem is, I'd want to customize it
some. Like, customize error pages, logging, etc.
I am also curios about something else. Back in some time, the PHP manual read that the HTTP server
is "for development only". The problem is, I do not want to package an apache webserver
into the bundle - or do some nodejs scripting for some webserver. I'd like to stay on a PHP
basis.
Would be great if you can explain some things to me here!
Related links for those curios:
The actual project, drag0n: https://github.com/IngwiePhoenix/drag0n
Deskshell (I maintain a fork and build the MacOS port): https://github.com/sihorton/appjs-deskshell
The current WebSocket client I am using for communication: https://github.com/Devristo/phpws
The Webserver was somewhere on google, the original file can be found within drag0n, to be exact,
here: https://github.com/IngwiePhoenix/drag0n/blob/master/drag0n.app/Contents/System/lib/php/WebServer.php
Kind regards, Ingwie