PHP Ratchet and WebRTC PHP Ratchet and WebRTC php php

PHP Ratchet and WebRTC


Almost all the tutorials says WebRTC is simple, but at the same time they keep repeating only the same webrtc.org basic examples and using almost only Node.js.

I found this nice early WebRTC+PHP GitHub project that codes a simple signaling server using PHP and MySQL (although it could be replace by a text file). I think it could be useful to you. Is outdated, last change was 6 years ago, but I could explain you the changes in the code needed to run it using PHP 7 and the last Firefox and Chrome versions.

I'm planning to share a fork when I could achieve to code a multiple (not a fixed number) users version. But the lack of examples make it harder.


So you want to develop a streaming webrtc example on a PHP website.

If you use shared hosting, it is going to be difficult with PHP because then you do not have commandline access on the server, which you need for a WebSocket implementation. Then you can use my project at https://github.com/nielsbaloe/webrtc-php to do WebRtc without websockets with SSE (ServerSideEvents). Works great for say less than hundred users.

If you are not on shared hosting, then you can use any PHP package which supports websocket, like Ratchet. However, that is what nobody does these days. You can also switch to using node.js and have a signalling server with less than 10 lines of code.


Yes, WebRTC works well with PHP hosts. The important fact here is that practically anything can be used as a signalling server. You can literally write SDP descriptions and ICE candidates down on paper and send them back and forth using homing pidgins. But where PHP is involved, yes, Ratchet, Workerman, Swoole etc can each be used for creating signalling servers. Most WebRTC gateways also have PHP friendly plugins allowing PHP hosts to play a more active roll in establishing connections between peers when conference servers, SFUs, MCUs etc are thrown into the mix.