Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Ratchet and WebRTC

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?

like image 704
Abraham Avatar asked Oct 20 '16 20:10

Abraham


People also ask

Can I use WebRTC with PHP?

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.

What is PHP Ratchet?

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.

How do I start a ratchet server?

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__ ) .


2 Answers

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.

like image 87
Leopoldo Sanczyk Avatar answered Oct 04 '22 13:10

Leopoldo Sanczyk


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.

like image 44
Niels Avatar answered Oct 04 '22 11:10

Niels