Difference between revisions of "PHP in Elphel cameras"

From ElphelWiki
Jump to: navigation, search
 
Line 1: Line 1:
== Introduction ==
+
== Why PHP? ==
 +
One of the main objectives of Elphel products is to  make them developer-friendly. Just opening of the camera internals (including source code, FPGA code, hardware schematics) is not enough without providing means to modify the cameras easily, and here [http://www.php.net PHP] comes to the rescue. It is powerful and efficient and is well known by many developers including those who may have problems to modify FPGA code or kernel drivers. It is much easier to try your custom applications written in PHP - just transfer the files to the camera (i.e. with ftp) and open them in the web browser.
 +
 
 +
PHP supports custom extensions written in C and we'll work (and I hope not just we at Elphel) to provide more custom function to combine flexibility and ease of use of the PHP with efficiency of native compiled code.
 +
 
 +
== PHP in Elphel cameras (models 353/363) ==
 +
Current version of PHP in Elphel cameras is 5.2.1, we will try to keep it (almost) current. As of now ( [[Release_notes|Elphel software version 7.1.6]]) there are two copies of PHP in the camera - one is working through [http://www.boa.org/ Boa web server] (traditional for Axis ETRAX based products) in CGI mode (port 80) and the other one in [http://en.wikipedia.org/wiki/FastCGI Fast CGI] mode through [http://www.lighttpd.net/ Lighttpd] on port 81. Fast CGI mode does not restart applications (like traditional CGI does) for each HTTP request but rather keeps them alive to serve multiple requests. In the case of large application like PHP itself it makes a big performance difference and allows usage of the PHP scripts in the camera without the penalty of slow responses - something really undesirable for [http://www.linuxdevices.com/articles/AT5951285077.html AJAX applications].
 +
 
 +
== How to use PHP in the camera ==
 +
It is very simple. It is the same as to try your HTML/JavaScript pages.  You just need to ftp you script to one of the two locations (or their subdirectories) in the camera. Examples below assume you have the default camera IP=192.168.0.9:
 +
* /var/html (visible as <nowiki>http://192.168.0.9:81/var/</nowiki> in the web browser) - recommended for experiments, if something goes wrong you can just power-cycle the camera and all your changes will be gone
 +
* /usr/html (visible as <nowiki>http://192.168.0.9:81/</nowiki> in the web browser) - permanent (until next full firmware upgrade ) storage in the camera flash memory. This second location is more dangerous as you can change the installed files and rebooting will not restore the default behaviour. Flash memory has limited number of write cycles and can develop additional bad blocks duruing usage, so this location is recommended for "final" files, already tested in /var/html.

Revision as of 17:22, 3 December 2007

Why PHP?

One of the main objectives of Elphel products is to make them developer-friendly. Just opening of the camera internals (including source code, FPGA code, hardware schematics) is not enough without providing means to modify the cameras easily, and here PHP comes to the rescue. It is powerful and efficient and is well known by many developers including those who may have problems to modify FPGA code or kernel drivers. It is much easier to try your custom applications written in PHP - just transfer the files to the camera (i.e. with ftp) and open them in the web browser.

PHP supports custom extensions written in C and we'll work (and I hope not just we at Elphel) to provide more custom function to combine flexibility and ease of use of the PHP with efficiency of native compiled code.

PHP in Elphel cameras (models 353/363)

Current version of PHP in Elphel cameras is 5.2.1, we will try to keep it (almost) current. As of now ( Elphel software version 7.1.6) there are two copies of PHP in the camera - one is working through Boa web server (traditional for Axis ETRAX based products) in CGI mode (port 80) and the other one in Fast CGI mode through Lighttpd on port 81. Fast CGI mode does not restart applications (like traditional CGI does) for each HTTP request but rather keeps them alive to serve multiple requests. In the case of large application like PHP itself it makes a big performance difference and allows usage of the PHP scripts in the camera without the penalty of slow responses - something really undesirable for AJAX applications.

How to use PHP in the camera

It is very simple. It is the same as to try your HTML/JavaScript pages. You just need to ftp you script to one of the two locations (or their subdirectories) in the camera. Examples below assume you have the default camera IP=192.168.0.9:

  • /var/html (visible as http://192.168.0.9:81/var/ in the web browser) - recommended for experiments, if something goes wrong you can just power-cycle the camera and all your changes will be gone
  • /usr/html (visible as http://192.168.0.9:81/ in the web browser) - permanent (until next full firmware upgrade ) storage in the camera flash memory. This second location is more dangerous as you can change the installed files and rebooting will not restore the default behaviour. Flash memory has limited number of write cycles and can develop additional bad blocks duruing usage, so this location is recommended for "final" files, already tested in /var/html.