PHPackages                             amnuts/phpiwire - 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. amnuts/phpiwire

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

amnuts/phpiwire
===============

A PHP extension (written using Zephir) that interfaces with wiringPi, allowing you to easily control your Raspberry Pi's GPIO using PHP.

13114C

Since Jun 22Pushed 10y ago1 watchersCompare

[ Source](https://github.com/amnuts/phpiwire)[ Packagist](https://packagist.org/packages/amnuts/phpiwire)[ RSS](/packages/amnuts-phpiwire/feed)WikiDiscussions master Synced 4w ago

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

PHPiWire
========

[](#phpiwire)

A wrapper for [wiringPi](http://wiringpi.com/) written in [Zephir](http://www.zephir-lang.com/) so that is can be compiled as an extension for PHP.

[![Flattr this git repo](https://camo.githubusercontent.com/7e3f46a36526479d701ef7f90a0f8c3ac2fbab3087446e2a9fceed75cd1ab802/687474703a2f2f6170692e666c617474722e636f6d2f627574746f6e2f666c617474722d62616467652d6c617267652e706e67)](https://flattr.com/submit/auto?user_id=acollington&url=https://github.com/amnuts/phpiwire&title=phpiwire&language=&tags=github&category=software)

Requirements
------------

[](#requirements)

This extension and the wiringPi library are intended to run on a RaspberryPi, so having a RaspberryPi is kind of a big requirement here! You also need to have Git installed, the wiringPi library, various build tools and the php development headers.

### Installing Git

[](#installing-git)

```
sudo apt-get update
sudo apt-get install git

```

### Installing wiringPi

[](#installing-wiringpi)

```
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build

```

If all goes well you should be able to run the gpio utility:

```
gpio -v

```

Full instructions for [installing wiringPi](http://wiringpi.com/download-and-install/).

### Installing zephir

[](#installing-zephir)

```
sudo apt-get install gcc make re2c php5 php5-json php5-dev libpcre3-dev
git clone https://github.com/phalcon/zephir
cd zephir
./install-json
./install -c

```

If all goes well you should be able to get the help info for zephir:

```
zephir help

```

Full instructions for [installing zephir](http://zephir-lang.com/install.html#installing-zephir).

Building the extension
----------------------

[](#building-the-extension)

```
git clone https://github.com/amnuts/phpiwire
cd phpiwire
zephir build

```

That will build and install the extension. You'll then have to add the extension to your php.ini file. You may find that you have two php.ini files, one for cli and one for web, so remember to add the extension to both. You'll want to add the line:

```
extension=phpiwire.so

```

Once this is done (and the web server restarted if you're adding the extension for web use and not just cli) you should be able to see the extension info when using the `phpinfo()` method or via the command line `php -i`.

Example
-------

[](#example)

Here's a very simple example of how to make an LED attached to pin 0 (using the wiringPi pin numbering scheme, BCM\_GPIO pin 17) blink on and off.

Assuming the LED is attached as shown:

[![Overview](https://camo.githubusercontent.com/2ffbcb9e87e67cfa0d491ed97265adcc81029deb143ed13241063d688e8b92f3/687474703a2f2f616d6e7574732e636f6d2f696d616765732f70687069776972652f626c696e6b312e6a7067)](https://camo.githubusercontent.com/2ffbcb9e87e67cfa0d491ed97265adcc81029deb143ed13241063d688e8b92f3/687474703a2f2f616d6e7574732e636f6d2f696d616765732f70687069776972652f626c696e6b312e6a7067)

```
