Simple PHP-Web-Gpio example switching leds
-
Try updating to the latest firmware, running
opkg update
and then tryingopkg install php5 php5-cgi
again.
Worked on my end.
-
Thanks for the pointers here @Rinus-van-Weert! I've managed to get PHP up and running without any fuss at all. Only last thing I'd add is whilst you're in modifying uhttpd you might want set up a secondary site.
So in
/etc/config/uhttpd
I've added the following below the main config definition... config uhttpd 'myapp' list listen_http '0.0.0.0:4000' list listen_http '[::]:4000' list interpreter '.php=/usr/bin/php-cgi' option home '/www/myapp' option cgi_prefix '/cgi-bin' option index_page 'index.php' option error_page '/oopsie.html' ...
The benifit (for me) being that, if you wanted to, you can access this site from the wider world without exposing the console.
Happy Hacking all
-
@Bo-Barry got it loaded, now don't know to 'run it'. First time PHP.
-
@Rinus-van-Weert thanks for the example.
find an small error on this line: "to the 'main' section of the /etc/config/uhhtpd file" => uhhtpd = uhttpd@Bo Barry you can run the program in your brouwser, http:\ipadres.for.onion\php\SwithcLeds.php
(if you put the script in www/php as SwitchLeds.php)I have also a relay expansion and make 2 functions for this:
function initRelay( ){ // init Relay expansion $command = 'relay-exp -i'; exec( $command ); //init } function writeRelay( $pen, $value){ if ( is_numeric( $value) ) // check if value is a number, could also be empty, if so write value tot output pin { $command = 'relay-exp ' .$pen .($value == 1 ? ' 1' : ' 0'); $res = exec( $command ); echo $res; } return $value; }
but there is no way to get the status of the relays. you only now the status when init.
-
@Lazar-Demin Hi Lazar, After opkg update, php5-cgi installed and I was able to run PHP srcipts, like SwitchLeds and others. Thanks for the help. I had recently done the opkg update, so how often does it need to be run?
-
@Yale-E.-Goldman Package indexes are usually updated daily, so it's recommended that you do an
opkg update
before eachopkg install
.
-
@Boken-Lin @Rinus-van-Weert How can I install the "SwitchLeds.php" file directly to the onion omega? Thanks for the awesome example, I have been looking at making a project like this, but I had no idea whatsoever on what to do.
Thanks,
Kyle
-
Hi, I have made a class that use this functions to control the Onion
php_onionI found an other interesting topic here that use an other approach
-
@Kyle I use pscp from putty with flag -scp
Use>PSCP.exe -scp -pw {onionpasw} source\* root@{onion.IP}:/www/php
to copy source to php directory
-
@Kyle from your Omega, you can also do a wget to get the file
wget --no-check-certificate https://community.onion.io/uploads/files/1446719911755-switchleds.php
-
@Anco-van-der-Kolk
@Fred-Blais
Thanks guys! will do!