PHPackages                             ronanguilloux/php-gpio - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ronanguilloux/php-gpio

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ronanguilloux/php-gpio
======================

GPIO-related utils &amp; toolkit PHP library

v1.0.0(12y ago)2678.0k58[5 issues](https://github.com/ronanguilloux/php-gpio/issues)[3 PRs](https://github.com/ronanguilloux/php-gpio/pulls)MITPHPPHP &gt;=5.3.0

Since Mar 29Pushed 6y ago37 watchersCompare

[ Source](https://github.com/ronanguilloux/php-gpio)[ Packagist](https://packagist.org/packages/ronanguilloux/php-gpio)[ Docs](https://github.com/ronanguilloux/php-gpio)[ RSS](/packages/ronanguilloux-php-gpio/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (6)Used By (0)

php-gpio
========

[](#php-gpio)

**php-gpio** is a simple PHP library to play with the Raspberry PI's GPIO pins.

It provides simple tools such as reading &amp; writing to pins.

[![Latest Stable Version](https://camo.githubusercontent.com/21499f40df3639eba6c81c19af6792d9ab82a875ec7d34ac0a7df3641feb5e66/68747470733a2f2f706f7365722e707567782e6f72672f726f6e616e6775696c6c6f75782f7068702d6770696f2f762f737461626c652e706e67)](https://packagist.org/packages/ronanguilloux/php-gpio) [![Build Status](https://camo.githubusercontent.com/78e6396e2a558fcdb4fa854de4813a561d8c12451ff830a33de8b9179e55aca5/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f726f6e616e6775696c6c6f75782f7068702d6770696f2e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/ronanguilloux/php-gpio) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/087fbc93c077c46d903ae5ecba9dcb4938a8ad4e219388576953f43115305b81/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f726f6e616e6775696c6c6f75782f7068702d6770696f2f6261646765732f7175616c6974792d73636f72652e706e673f733d31393965363533623765633936323735393338343362613135633936316639633062653737303164)](https://scrutinizer-ci.com/g/ronanguilloux/php-gpio/) [![SensioLabsInsight](https://camo.githubusercontent.com/1dc302432faf4021424ca737a192d6d5b6508f44033ba544c53d0c4b0f27119f/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f66646534326164622d333434642d343035352d623738642d3230623539383034306163382f6d696e692e706e67)](https://insight.sensiolabs.com/projects/fde42adb-344d-4055-b78d-20b598040ac8) [![Total Downloads](https://camo.githubusercontent.com/d0c365ecb205ce3cfc54abdc5ceea967e858dee38ff53f00122b9ed0599566cd/68747470733a2f2f706f7365722e707567782e6f72672f726f6e616e6775696c6c6f75782f7068702d6770696f2f646f776e6c6f6164732e706e67)](https://packagist.org/packages/ronanguilloux/php-gpio)

[![Circuit snapshot](https://camo.githubusercontent.com/6d7e4ee064dea9d604f2817fab531c8fbbbdf3c8cc62b6834b67f7ddd52aadb5/68747470733a2f2f7261772e6769746875622e636f6d2f726f6e616e6775696c6c6f75782f74656d70657261747572652d70692f6d61737465722f7265736f75726365732f696d616765732f6d6f756e74696e672e6a7067)](https://camo.githubusercontent.com/6d7e4ee064dea9d604f2817fab531c8fbbbdf3c8cc62b6834b67f7ddd52aadb5/68747470733a2f2f7261772e6769746875622e636f6d2f726f6e616e6775696c6c6f75782f74656d70657261747572652d70692f6d61737465722f7265736f75726365732f696d616765732f6d6f756e74696e672e6a7067)

\[UPDATE Fall 2014\] Now compatible with both Raspberry Pi **B Model &amp; B+ Revision**

Tl;dr
-----

[](#tldr)

```
- "Hey, I just want to blink a LED from my raspberry pi hosted website!"
- "OK good guy: git clone https://github.com/ronanguilloux/php-gpio-web.git`
   & remember to come back here when you're lost ;-)"

```

=&gt; [php-gpio-web: a simple example for you to play with Leds &amp; PHP](https://github.com/ronanguilloux/php-gpio-web)

GPIO
----

[](#gpio)

General Purpose Input/Output (a.k.a. GPIO) is a generic pin on a chip whose behavior (including whether it is an input or output pin) can be controlled (programmed) through software. The Raspberry Pi allows peripherals and expansion boards (such as the Rpi Gertboard) to access the CPU by exposing the inputs and outputs.

For further informations about the Raspberry Pi's GPIO capabilities, see docs &amp; schemas at [http://elinux.org/RPi\_Low-level\_peripherals](http://elinux.org/RPi_Low-level_peripherals).

For Raspbeery Pi's GPIO controlling *LEDs*, have a look at a sample complete circuit diagram for a single LED, with detailled explanations &amp; schemas, [here](https://projects.drogon.net/raspberry-pi/gpio-examples/tux-crossing/gpio-examples-1-a-single-led/).

For Raspbeery Pi's GPIO controlling *sensors*, check the [DS18B20 (temperature sensor)](http://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing/overview) in action [here](https://github.com/ronanguilloux/temperature-pi)

Hardware prerequisites
----------------------

[](#hardware-prerequisites)

After having installed &amp; wired your LED &amp; resistor on a breadboard, add appropriate modules from the Linux Kernel:

For *LEDs*, enable the gpio module :

```
$ sudo modprobe w1-gpio
```

([see a complete circuit diagram for a single LED + explanations &amp; schemas here](https://projects.drogon.net/raspberry-pi/gpio-examples/tux-crossing/gpio-examples-1-a-single-led/))

For *sensors*, enable the appropriate sensor. By example for a [DS18B20 1-Wire digital temperature sensor](http://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing/overview):

```
$ sudo modprobe w1-therm
```

([see the DS18B20 in action on a Raspberry Pi here](https://github.com/ronanguilloux/temperature-pi))

To load such kernel modules automatically at boot time, edit the `/etc/modules` file &amp; add these two lines:

```
w1-gpio
w1-therm

```

Installation
------------

[](#installation)

The recommended way to install php-gpio is through [composer](http://getcomposer.org).

Just run these three commands to install it

```
$ sudo apt-get install git
$ wget http://getcomposer.org/composer.phar
$ php composer.phar create-project --stability='dev' ronanguilloux/php-gpio intoYourPath
```

Now you can add the autoloader, and you will have access to the library:

```
