I am trying to develop streaming webrtc on a PHP website.
I want to establish streaming peer to peer with webrtc.
I know webrtc works fine on node and socket to make all the configuration to stablish webrtc connection.
Can I use Ratchet and PHP in place of node and socket?
Does Ratchet support https?
Most of the WebRTC example use node. js server and JavaScript but it can be developed using PHP. You need to implement Webscoket server or BOSH server using PHP to send and receive from client.
Ratchet is a loosely coupled PHP library providing developers with tools to create real time, bi-directional applications between clients and servers over WebSockets. This is not your Grandfather's Internet.
Create the HTTP Server Open the file app. php and add the following code: <? php use Ratchet\Server\IoServer; use Ratchet\Http\HttpServer; use Ratchet\WebSocket\WsServer; use MyApp\Socket; require dirname( __FILE__ ) .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With