[Red5] Red5 and PHP - newbie

Andy Shaules bowljoman at hotmail.com
Thu Oct 30 18:21:36 PST 2008


Walter is advocating my favorite.
AMF + php All the way!

Both php to java and java to php are seamless.

----- Original Message ----- 
From: "Daniel Rossi" <electroteque at gmail.com>
To: <red5 at osflash.org>
Sent: Thursday, October 30, 2008 5:06 PM
Subject: Re: [Red5] Red5 and PHP - newbie


> It can either work with a PHP running on Apache or directly in cgi  mode. 
> The cgi mode sounds great (assuming it has the security settings  in place 
> and in fastcgi mode if tomcat can do that ??).
>
> All you need to do is place the supplied demo webapp into the red5 
> webapps folder and point the config to the right php binary. It seems  to 
> load non spring tomcat descriptors fine oddly enough, so any tomcat 
> webapp could be placed into red5 without much effort.
>
> On 31/10/2008, at 11:58 AM, Walter Tak wrote:
>
>> The bridge can execute php-code (dynamic) and scripts. That requires  php 
>> to be present on the system and it's more or less always used in 
>> cooperation with Apache or IIS (on windows).
>>
>> php-java-bridge has to be integrated within Red5 in order for you to  be 
>> able to call from your application-class your php-scripts.
>>
>> The software seems pretty mature and thus stable, the integrate  could be 
>> a hassle ; I haven't found any sites describing integrating  it with Red5 
>> or vice versa. Most uses are php-developers wanting to  try to talk to 
>> existing java-applications. You don't want that , you  want Red5 to talk 
>> to PHP for validation, data storage and retrieval  etcetera.
>>
>> If you want to use PHP backend-logic with Red5 then the most used 
>> option, and most independant one as well, is to do a remoting-call  which 
>> is a http request to a webserver (e.g. Apache) that serves php- pages and 
>> has a AMF-gateway. The remoting-call uses the AMF protocol  to 
>> communicate with external sites and the AMF-gateway on the  webserver is 
>> a framework that encodes results from php-scripts into  the AMF-protocol.
>>
>> AMFPHP: http://www.amfphp.org/
>>
>> SabreAMF: http://osflash.org/sabreamf
>>
>> Some major downsides are:
>>
>> - latency between red5 and the external server
>> - serialisation of data isn't perfect (convert a php array into a  AMF 
>> packet, send it over the network, convert it into something java  can 
>> parse)
>> - stateless (you need to establish contact over and over)
>> - need both PHP- and Java-coders
>>
>> possible benefits:
>>
>> - allows for totally separated servers
>> - easier multi-tier setup
>> - allows PHP-coders to do their job and Java/Red5 coders to do theirs
>> - could be easy to setup a loadbalanced and failover backend ; just  let 
>> the/all Red5 server(s) call the gateway on a certain hostname  and have a 
>> hardware loadbalancer, bound to that name (ip) distribute  the incoming 
>> calls to an available php/webserver
>>
>> A combined solution could be to install all services (webserver/php/ 
>> (database)/java/Red5) on one machine, lowering latency and removing  the 
>> bandwidth/network-bottleneck
>>
>> Your message made me looking at the php-java-bridge for a while but  even 
>> with quite some years of experience on both java and php I  personally am 
>> a bit shy of trying to actually use it to "glue" java  and php together. 
>> For 'fun' or 'research' projects it might be a  convenient solution where 
>> it could prove itself to be useful in a  production environment.
>>
>> Another, bit advanced, option is to create a socket-server with php, 
>> that's a php-script that's run from commandline and listens on a 
>> user-defined socket and have your red5-application make a socket- 
>> connection to that php-script. The data passed over the line would  be 
>> raw (strings/binary) and you'd have to do write all  (de-)serialisation 
>> of objects/arrays etc yourself. It would be fast  and stateful, doesn't 
>> require the integration of third-party- software like php-java-bridge.
>>
>> Socketservers and php isn't new ; 
>> http://devzone.zend.com/article/1086-Writing-Socket-Servers-in-PHP is 
>> written in 2003.
>> A full Flash 8 + PHP5 socketserver doc can be found at 
>> http://www.kirupa.com/developer/flash8/php5sockets_flash8.htm (2006)
>>
>> Besides all these pure-backend solutions (where all interaction is 
>> totally hidden from the user and thus is near 100% safe) you could  also 
>> do a very simple remoting-call from the client (Flash) to an  AMFPHP 
>> gateway instead of using Red5 as a traffic-cop and spider-in- the-web. 
>> For non-confidential data that is the most often used option.
>>
>> Walter
>>
>
>
> _______________________________________________
> Red5 mailing list
> Red5 at osflash.org
> http://osflash.org/mailman/listinfo/red5_osflash.org
> 




More information about the Red5 mailing list