how can I use php with webiopi

1,322 views
Skip to first unread message

shufan zeng

unread,
Feb 3, 2014, 6:33:54 AM2/3/14
to web...@googlegroups.com
I create a php file under localhost:8000,and set it as welcome file in config, it works and I can now control gpio, but I find php code in my file can not run ,but if I delete :8000 and set address as localhost/xxx.php it works! 

Eric PTAK

unread,
Feb 3, 2014, 2:26:17 PM2/3/14
to web...@googlegroups.com
Depend on what you want to do with PHP ?
You can just not use it and rely completely on Javascript and Python instead ;)


On Mon, Feb 3, 2014 at 12:33 PM, shufan zeng <shufa...@gmail.com> wrote:
I create a php file under localhost:8000,and set it as welcome file in config, it works and I can now control gpio, but I find php code in my file can not run ,but if I delete :8000 and set address as localhost/xxx.php it works! 

--
You received this message because you are subscribed to the Google Groups "WebIOPi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webiopi+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Martyn Wheeler

unread,
Apr 11, 2014, 7:21:12 PM4/11/14
to web...@googlegroups.com
Sorry to bring up this old thread, but I'd like to incorporate a navigation menu on my webiopi pages. One approach would be to use a php file to write out the menu in the body of each page. I can't, however, get php to work on my pages. Just wondering what I might be doing wrong or if this is not feasible?

Thanks in advance,

Martyn

Toshi Bass

unread,
Apr 12, 2014, 2:40:11 AM4/12/14
to web...@googlegroups.com
Martyn

PHP is a server side scripting language and so is Webiopi, there maybe specific things it can do that Webiopi cannot do, I don't know, but if all you want is a navigation menu to point to different pages then as you say "write out the menu in the body of each page" and it will work in Webiopi just like it would in PHP, the key here is don't over complicate unless its absolutely necessary. 

Toshi

hal8000b

unread,
Apr 12, 2014, 10:34:14 AM4/12/14
to web...@googlegroups.com

Martyn,
Simple example of hozizontal menu below done in HTML and CSS:
This needs to be places inside the <body> </body> tags
 
<body>
<div class="nav">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="app/gpio-header">GPIO Pins</a></li>
<li><a href="http://192.168.0.4">Pi 2</a></li>
<li><a href="status.htm">System Status</a></li>
/ul>
</div>


This creates a set of unordered links, the index.html is your current page (Home) as displayed on button, the
GPIO Pins is a link to the GPIO pins, Pi 2, could be a link to a second Pi on your home network, or any other
page for that matter, and System Status, is just an example of another page called system status.

To style the links use CSS code between the <style> </style> tags:
.nav { margin 0em;
font-size: 22px;
width: 100%;
background-color: #3a3a4b;
height: 38px; }

.nav ul { display: inline; }

.nav li { display: inline;
padding: 0em 1em;
border: 5px outset #3a3a3a;
text-align: center;
}

.nav a:link, .nav a:visited { text-decoration: none; color: #a0522d; }
.nav a:hover { color: #ffd700; }
.nav a:focus { color: #fff; }

The above will produce a simple hozizontal menu with grey background, brown text,
which changes to yellow when the mouse is over. You dont need, PHP, javascript,
or dreamweaver for these simple menues. Hope that helps.

Martyn Wheeler

unread,
Apr 12, 2014, 6:19:06 PM4/12/14
to web...@googlegroups.com
Thanks very much for your replies, I have it working now with the code you sent.

Slappy

unread,
Jun 29, 2014, 4:53:19 AM6/29/14
to web...@googlegroups.com
I've installed lighttpd/sqlite and php on my rpi in the hope of being able to run php with webiopi. I know you aren't particularly happy with this but I want it! Running through port :8000 webiopi runs and switches the gpios but php doesn't work. Running through port :80 runs php but webiopi doesn't work, both don't run together. That said, pages named page.php will display but no php code is executed.

Can you suggest how I might get both to play happily please? I wish to 'include' files through php instead of using frames and also to include some system info such as CPU load & temperature and some file system info, which I can do in php.

Any clues?
Thanks!

barbudor

unread,
Jun 29, 2014, 5:42:15 AM6/29/14
to web...@googlegroups.com
Hi Slappy

What you want to achieve is not clear to me.

- Samples in WebIOPi uses "index.htlm" files that use JavaScript to interact with WebIOPi. Thoses "index.html" files could be made as "index.php" server-side script which allow the base page to be generated by PHP framework instead of pure static HTML. this can allow you to use a page-building PHP framework. However, you shoudl still rely on client-side JavaScript to make the pages dynamic and interact with the user and with WebIOPi.

- Your PHP server-side scripts could interfact with WebIOPi using REST API. This allows the building of page to depend on WebIOPi interaction, but to make the page to dynamically interact with the user, you're back on step1 : JavaScript.

- You can't replace WebIOPi "script.py" mecanism with PHP. Those must remains in Python.

Best regards

Barbudor





--
You received this message because you are subscribed to the Google Groups "WebIOPi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webiopi+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Slappy

unread,
Jun 29, 2014, 8:28:45 PM6/29/14
to web...@googlegroups.com
Thanks Barbu, I'm beginning to understand now. I don't actually wish to drive webiopi with php, I'm just more familiar with it than javascript and want to add more dynamic content to my 'control panel' page. I've looked into using javascript to achieve what I want, it seems do-able. Also looking into REST API, thank you for your help.

barbudor

unread,
Jun 30, 2014, 8:24:02 AM6/30/14
to web...@googlegroups.com

I may said something wrong : webiopi webserver cannot serve php page (as far as i know)
You need a separated web server such as apache to handle php. And wepiopi for the rest api.

Barbudor

Le 30 juin 2014 02:28, "Slappy" <rotor...@gmail.com> a écrit :
Thanks Barbu, I'm beginning to understand now. I don't actually wish to drive webiopi with php, I'm just more familiar with it than javascript and want to add more dynamic content to my 'control panel' page. I've looked into using javascript to achieve what I want, it seems do-able. Also looking into REST API, thank you for your help.

Reply all
Reply to author
Forward
0 new messages