Thanks for sharing, but I am really not happy to install PHP (or using it) on my local system. I see you state you may re-write it in Python, if this happens I look forward to trying it!
For PHP there's the option of binary distribution using php-micro, sadly not all devs are into it as "just brew". They don't realize that the end user isn't a PHP dev and that having to install the runtime is an annoying step.