PHP code example of ronanguilloux / php-gpio

1. Go to this page and download the library: Download ronanguilloux/php-gpio library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ronanguilloux / php-gpio example snippets


(...)
$result = exec('sudo -t /usr/bin/php ./blinker 17 20000'); // calling the API client file
(...)
 bash
$ sudo apt-get install git
$ wget http://getcomposer.org/composer.phar
$ php composer.phar create-project --stability='dev' ronanguilloux/php-gpio intoYourPath
 php


 php


 php


io\Gpio;

echo "Setting up pin 17\n";
$gpio = new GPIO();
$gpio->setup(17, "out");

echo "Turning on pin 17\n";
$gpio->output(17, 1);

echo "Sleeping!\n";
sleep(3);

echo "Turning off pin 17\n";
$gpio->output(17, 0);

echo "Unexporting all pins\n";
$gpio->unexportAll();
 php


# blinkTester.php

# Blinks the LED wired to the GPIO #17 pin with 0.2 second delay:
$result = exec('sudo -t /usr/bin/php ./blinker 17 20000');
 bash
$ php blinkTester.php