4 ms·
Implemented a websocket server in PHP as a curiosity, which is a php cli daemon independent of apache. Its absolutely awesome barring having to work with the w
by SDGT 13y ago
Implemented a websocket server in PHP as a curiosity, which is a php cli daemon independent of apache.
Its absolutely awesome barring having to work with the websocket framing protocol with ordinal casts, etc. PHP has an odd flavor of hex/ binary arithmetic. You pretty much just pull characters out of a string byte by byte and use bit shifting/ ANDing to get a message decoded.
And the best part! No need for anything like APC for the cli; it's useless as the daemon doesn't work like a standard PHP lifecycle in apache.
- pionar 13y agoI did this for a project in 5.3 (client: "PHP EVERYTHING"), it wasn't as difficult as I thought it'd be, but I will admit, there are better solutions.
- astrodust 13y agoIt's the "better solutions" that make me wonder why people go down this road for any reason other than academic curiosity. Given an arbitrary back-end written in Python, Ruby, Go, Perl, Java, Scala or PHP I would expect, nine times out of ten, the bad apple to be PHP. Anyone who knows how to program PHP properly, and by that I mean using all of the modern conventions, would be far more productive in something like Java or Python where they didn't have twenty years of appallingly bad design decisions influenced by its role as a web scripting language weighing down their code.
- coldtea 13y ago>Anyone who knows how to program PHP properly, and by that I mean using all of the modern conventions, would be far more productive in something like Java or Python where they didn't have twenty years of appallingly bad design decisions influenced by its role as a web scripting language weighing down their code. Yes, because Java doesn't have it's own twenty years of bad decisions...
- astrodust 13y agoYou can build Android apps in Java. It's not pigeonholed.