PHPackages                             pkj/raspberry-piface-api - 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. pkj/raspberry-piface-api

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

pkj/raspberry-piface-api
========================

Lets you control your PiFace for Raspberry PI with PHP.

145962[1 issues](https://github.com/peec/raspberry-piface-api/issues)PHP

Since Oct 1Pushed 12y ago1 watchersCompare

[ Source](https://github.com/peec/raspberry-piface-api)[ Packagist](https://packagist.org/packages/pkj/raspberry-piface-api)[ RSS](/packages/pkj-raspberry-piface-api/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Build Status](https://camo.githubusercontent.com/fbaade3ac1ea93033cc23f079c1ce972b0ad728e197019f229774940deecef00/68747470733a2f2f7472617669732d63692e6f72672f706565632f7261737062657272792d7069666163652d6170692e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/peec/raspberry-piface-api)

Raspberry PI - PiFace API for PHP 5.4+
======================================

[](#raspberry-pi---piface-api-for-php-54)

I ported the [original Python library](https://github.com/piface/pifacedigitalio) to PHP. This library works almost the same as the python library.

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

[](#requirements)

- Hardware: **Raspberry PI** and **PiFace module**.
- PHP 5.4+ installed
- You also need to add the php SPI extension, compile it and configure, see: [https://github.com/frak/php\_spi](https://github.com/frak/php_spi)
- Apache if you want to run commands from web scripts.

Don't worry, follow the guides below to get started:

Setting up the environment
--------------------------

[](#setting-up-the-environment)

Few things you need to install your environment, here is some instructions.

```
# Install php + git
sudo apt-get install php5 php5-dev php5-cli git

# Install php SPI
git clone git://github.com/frak/php_spi.git ~/php_spi
cd ~/php_spi
phpize
./configure --enable-spi
make
make test
sudo make install
```

Install
-------

[](#install)

Install with Composer:

Here is some commands to your new project in `~/myphpiface` (in your home directory):

```
mkdir ~/myphpiface
cd ~/myphpiface
touch ~/myphpiface/composer.json
echo '{ "require": { "pkj/raspberry-piface-api": "dev-master" } }' >> ~/myphpiface/composer.json
curl -sS https://getcomposer.org/installer | php
php composer.phar install
```

This will create a `vendor` directory where the library is installed.

Usage:
------

[](#usage)

Create a PHP script named `test_piface.php` (We assume that you place `test_piface.php` where `composer.json` file is.) and paste this in the file:

```
use Pkj\Raspberry\PiFace\PiFaceDigital;

dl("spi.so"); // Load the SPI extension.
require 'vendor/autoload.php';

$dev = PiFaceDigital::create();
// Run once.
$dev->init();

$dev->getLeds()[0]->turnOn();
sleep(2);
$dev->getLeds()[0]->turnOff();

// $dev->getInputPins();
// $dev->getOutputPins();
// $dev->getLeds();
// $dev->getRelays();
// $dev->getSwitches();

// Turn on relay 0
$dev->getRelays()[0]->turnOn();

// Get 0/1 of input pin 3 (There are 8 pins, 0-7)
$dev->getInputPins()[3]->getValue();

// Toggle a value on a output pin (5 in this example)
$dev->getOutputPins()[5]->toggle(); // 0
$dev->getOutputPins()[5]->toggle(); // 1
$dev->getOutputPins()[5]->toggle(); // 0

```

And test:

```
php -f test_piface.php
```

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/88b748fa2f0dcacab307a6305e98032de7adb93f955bbaf3c6fe029a7369ac84?d=identicon)[peec](/maintainers/peec)

---

Top Contributors

[![peec](https://avatars.githubusercontent.com/u/131546?v=4)](https://github.com/peec "peec (23 commits)")[![janunger](https://avatars.githubusercontent.com/u/391021?v=4)](https://github.com/janunger "janunger (4 commits)")

### Embed Badge

![Health badge](/badges/pkj-raspberry-piface-api/health.svg)

```
[![Health](https://phpackages.com/badges/pkj-raspberry-piface-api/health.svg)](https://phpackages.com/packages/pkj-raspberry-piface-api)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
