Thursday, June 5, 2008

Exploring PHP as a candidate for the front end UI

I focused my attention on learning PHP the past 2 weeks. I first struggled a bit around in finding the right tools to test and write PHP/HTML combination. Finally the package XAMPP came out as a great bundle of a web server, a PHP interpreter and a mysql database. Be ware this is not intended to install on the NGW but on the host PC to test written code first. This is a lot easier than always transfer the files to the target. I also installed the version 6.1 of “netbeans early access php” as the IDE. I started to read some e-book based on PHP version 4 to feed the basic skills. It went very smoothly and I saw a lot of good and simple program techniques rising up as I continued reading. The best thing in my opinion is without a doubt making some exercise to master the concepts. The way I prefer is cutting this concepts in to smaller pieces and study them separately first. So over night I dreamt of some small math application covering all my basic learned skills. It was in fact a simple multiplication test with 3 levels of difficulty. I tried to master reading/writing from/to files as I needed it for saving session data. Version 1 was born. An example can be viewed if NGW is running on:

http://guyvo.no-ip.biz/php1/

As this exercise got some final form I rapidly saw that there were a few shortcomings like an overloaded GUI and working with more than one client browser at the same time was not possible. So I continued studying cookies and sessions variables. I adapted version 1 very easily with these concepts. An example can be viewed if NGW is running on:

http://guyvo.no-ip.biz/php2/

Still some important concepts to learn and I plan to buy the book "PHP5 & MySQL" to always have a reference with me. But as I said before the chances are high to go for this solution as the front end domotic interface, and this can only be confirmed now. I get the feeling PHP is capable of doing the job. Using this as a final UI will give us more portability than ever before because HTML is vastly spread now and everyone has at least one browser and PHP (written in C) is easy to port to several popular cpu platforms. (AVR, ARM , MIPS ,....) But I will dedicate a complete topic on the portability of this project in one of my future blogs here.

PS

I can add one more computer languages to my list ;-)

2 comments:

Anonymous said...

Hi!
I started programming the NGW one week ago and today i tried to execute my php script on the ngw, but it doesn't work.
The location of the file is /www/index.php
So do you know what i make wrong ??

guyvo said...

Hard to say with that little on information.

But you need to have ligthtpd webserver with PHP libs installed.

Normally if you point your home directory to /www in the config file and put a simple PHP file in that directory it must be working.

Guy