10. Using Yocto-Display with PHP
PHP is, like Javascript, an atypical language when interfacing with hardware is at stakes.
Nevertheless, using PHP with Yoctopuce modules provides you with the opportunity to very easily
create web sites which are able to interact with their physical environment, and this is not available to
every web server. This technique has a direct application in home automation: a few Yoctopuce
modules, a PHP server, and you can interact with your home from anywhere on the planet, as long
as you have an internet connection.
PHP is one of those languages which do not allow you to directly access the hardware layers of your
computer. Therefore you need to run a virtual hub on the machine on which your modules are
connected.
To start your tests with PHP, you need a PHP 5.3 (or more) server
1
, preferably locally on you
machine. If you wish to use the PHP server of your internet provider, it is possible, but you will
probably need to configure your ADSL router for it to accept and forward TCP request on the 4444
port.
10.1. Getting ready
Go to the Yoctopuce web site and download the following items:
• The PHP programming library
2
• The VirtualHub software
3
for Windows, Mac OS X, or Linux, depending on your OS
Decompress the library files in a folder of your choice accessible to your web server, connect your
modules, run the VirtualHub software, and you are ready to start your first tests. You do not need to
install any driver.
10.2. Control of the Display function
A few lines of code are enough to use a Yocto-Display. Here is the skeleton of a PHP code snipplet
to use the Display function.
include(
'yocto_api.php'
);
include(
'yocto_display.php'
);
1
A couple of free PHP servers: easyPHP for Windows, MAMP for Mac OS X.
2
www.yoctopuce.com/EN/libraries.php
3
www.yoctopuce.com/EN/virtualhub.php
www.yoctopuce.com
47
Содержание Yocto-Display
Страница 1: ...Yocto Display User Manual...
Страница 2: ......
Страница 40: ...34 www yoctopuce com...
Страница 52: ...46 www yoctopuce com...
Страница 84: ...78 www yoctopuce com...
Страница 92: ...86 www yoctopuce com...
Страница 130: ...124 www yoctopuce com...
Страница 158: ...22 High level API Reference 152 www yoctopuce com On failure throws an exception or returns a negative error code...
Страница 422: ...416 www yoctopuce com...
Страница 424: ...24 Characteristics 418 www yoctopuce com...