PHPackages                             noccylabs/raspio - 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. noccylabs/raspio

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

noccylabs/raspio
================

Raspberry Pi GPIO/Peripheral Library

0.1.1(12y ago)125GPL-2.0+PHP

Since Jan 20Pushed 12y ago1 watchersCompare

[ Source](https://github.com/noccylabs/php-raspio)[ Packagist](https://packagist.org/packages/noccylabs/raspio)[ RSS](/packages/noccylabs-raspio/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (3)Used By (0)

RaspIo
======

[](#raspio)

Installing
----------

[](#installing)

Install using composer:

```
composer require "noccylabs/raspio:dev-master"

```

Or by cloning the github repository:

```
git clone git@github.com:noccylabs/php-raspio

```

Note that composer will take care of the autoloading; if you clone the repository you have to take care of that yourself.

Getting Started
---------------

[](#getting-started)

On a Raspberry Pi, just call on `RaspberryPi::getInstance()` to get an instance of the board driver.

```
use RaspIo\RaspberryPi;

// Get an instance of the Pi
$pi = RaspberryPi::getInstance();

```

`getInstance()` will find the first registered board driver that doesn't throw an exception, make sure it's an instance of `RaspIo\RaspberryPi`, and then use that for subsequent calls to `getInstance()`.

Devices are registered in the board driver constructor or in device drivers with a call to the `registerDevice($id,$device)` method. This makes them available via their respective properties as well as the `getDevice()` method.

```
// Like this
$gpio = $pi->gpio;
// Or this
$gpio = $pi->getDevice("gpio");

```

Devices can also be aliased, by calling `registerAlias($alias,$id)`. This is used to define the default devices when more than one of the device type may be available on the board.

You can get the info on the board detected by calling `getVersion()`:

```
printf("Board: %s\n", $pi->getVersion());

```

Devices can also be iterated over, or accessed via `getRegisteredDevices()`(and `getRegisteredAliases()`).

```
printf("Devices:\n");
foreach($pi as $device=>$obj) {
    printf("  %s => %s\n", $device, get_class($obj));
}

printf("Aliases:\n");
foreach($pi->getRegisteredAliases() as $alias=>$device) {
    printf("  %s -> %s\n", $alias, $device);
}

```

### ...on any other platform

[](#on-any-other-platform)

If you will be using or testing cose using RaspIo on a platform that is not supported, you can enable emulation.

```
use RaspIo\RaspberryPi;

// Add the emulated rev2 board. This must be done before the first
// call to RaspberryPi::getInstance()
RaspberryPi::addBoardDriver("RaspIo\\Board\\EmulatedRev2Board");
// Get an instance of the Pi
$pi = RaspberryPi::getInstance();

```

Using the devices
-----------------

[](#using-the-devices)

### GPIO

[](#gpio)

The GPIO is available with the device id `gpio`, and it should be a class implementing the interface `RaspIo\Device\Gpio\IGpioMapper`. It is normally an instance of `RaspIo\Device\Gpio\GpioMapper`.

```
// Get Pi instance
$pi = RaspberryPi::getInstance();

// Export and set direction
$pin = $pi->gpio->export(0)->setDirection("out");

// Write to the pin
$pin->setValue(1);

```

Available methods are defined in `RaspIo\Device\Gpio\IGpioExport`:

- `setDirection($dir)` and `getDirection()` to set the gpio direction to one of `in` or `out`.
- `setValue($val)` and `getValue()` to set the gpio value to either `1` or `0`.

To unexport a pin, call on `unexport()` on the GpioMapper:

```
// Unexport the pin
$pi->gpio->unexport(0);

```

### UART

[](#uart)

UART support is not yet implemented.

### Dummy Devices

[](#dummy-devices)

Dummy devices are placeholders for not yet implemented devices.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

4494d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8d64de61943112cad68fd83b1068d157d6c96890d23959855f6a1ea42bcdcce3?d=identicon)[noccy80](/maintainers/noccy80)

---

Top Contributors

[![noccy80](https://avatars.githubusercontent.com/u/1434055?v=4)](https://github.com/noccy80 "noccy80 (7 commits)")

### Embed Badge

![Health badge](/badges/noccylabs-raspio/health.svg)

```
[![Health](https://phpackages.com/badges/noccylabs-raspio/health.svg)](https://phpackages.com/packages/noccylabs-raspio)
```

PHPackages © 2026

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