PHPackages                             embedded-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. embedded-php/gpio

ActivePhp-ext[Utility &amp; Helpers](/categories/utility)

embedded-php/gpio
=================

An object-oriented wrapper to the gpio Linux Userspace ABI

641[2 PRs](https://github.com/embedded-php/ext-gpio/pulls)CCI passing

Since Dec 23Pushed 3mo ago2 watchersCompare

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

READMEChangelogDependenciesVersions (3)Used By (0)

GPIO PHP Extension
==================

[](#gpio-php-extension)

The GPIO PHP Extension provides an object-oriented wrapper to the [gpio](https://www.kernel.org/doc/Documentation/gpio/gpio.txt) Linux Userspace ABI that gives users the ability to write code that interacts with the [general-purpose input/output](https://en.wikipedia.org/wiki/General-purpose_input/output)pins available in Linux-based [Single-Board Computers](https://en.wikipedia.org/wiki/Single-board_computer) such as the [Raspberry Pi](https://en.wikipedia.org/wiki/Raspberry_Pi).

Acknowledgements
----------------

[](#acknowledgements)

The initial version of this extension was based on [libgpiod](https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/) and still is heavily inspired by it.

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

[](#requirements)

- PHP &gt;= 8.0 (either NTS or ZTS version);

> **Note:** if you are using this extension on Raspbian or Raspberry Pi OS, the user executing the script **must**belong to the **gpio** group or you may run into "Permission denied" errors.

On **Raspbian** or **Raspberry Pi OS**:

**PHP 8.0**:

```
sudo apt install php8.0-cli php8.0-dev php8.0-phpdbg
```

**PHP 8.1**:

```
sudo apt install php8.1-cli php8.1-dev php8.1-phpdbg
```

Building
--------

[](#building)

```
phpize
./configure
make
make test
```

Quick start
-----------

[](#quick-start)

A simple "softwire" example that reads the value from input pin #2 and writes its value to output pin #3:

```
$chip = new GPIO\Chip('/dev/gpiochip0');
$p2 = $chip
  ->getPin(2)
  ->asInput('softwire');
$p3 = $chip
  ->getPin(3)
  ->asOutput('softwire');

$p2->isHigh() ? $p3->setHigh() : $p3->setLow();
```

Stubs
-----

[](#stubs)

After changing any of the [stubs](stubs/), the main [stub file](phpgpio.stub.php) must be updated by running the command below.

```
php stubs/update-main-stup.php
```

Once the stub is updated, the regular build process can be executed.

> **Note:** The main stub file ([phpgpio.stub.php](phpgpio.stub.php)) is a generated file, edit the files on the [stubs](stubs/) folder instead.

Classes
-------

[](#classes)

ClassDescription[GPIO\\Chip](stubs/Chip.php)Represents a GPIO chip.[GPIO\\Event](stubs/Event.php)Represents a GPIO event.[GPIO\\Exception](stubs/Exception.php)GPIO base exception.[GPIO\\Pin](stub/Pin.php)Represents a single GPIO pin.[GPIO\\Pins](stubs/Pins.php)Represents a collection of GPIO pins.Tools
-----

[](#tools)

NameDescription[gpiodetect.php](tools/gpiodetect.php)List all GPIO chips, print their labels and number of GPIO pins.[gpioinfo.php](tools/gpioinfo.php)Print information about all pins of the specified GPIO chip(s) (or all gpiochips if none are specified).Supported Hardware
------------------

[](#supported-hardware)

The table below lists the supported and tested chips.

SoCModel[BCM2835](tests/BCM2835.phpt)[Raspberry Pi 1 and Zero](https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/README.md)[BCM2836](tests/BCM2836.phpt)[Raspberry Pi 2](https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2836/README.md)[BCM2837](tests/BCM2837.phpt)[Raspberry Pi 3 (and later Raspberry Pi 2)](https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2837/README.md)[BCM2837B0](tests/BCM2837B0.phpt)[Raspberry Pi 3B+ and 3A+](https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2837b0/README.md)[BCM2711](tests/BCM2711.phpt)[Raspberry Pi 4B](https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2711/README.md)Alternatives
------------

[](#alternatives)

- [PiPHP/GPIO](https://github.com/PiPHP/GPIO)
- [ronanguilloux/php-gpio](https://github.com/ronanguilloux/php-gpio)
- [Volantus/php-pigpio](https://github.com/Volantus/php-pigpio)

Other Languages
---------------

[](#other-languages)

- Golang: [periph/conn](https://github.com/periph/conn)
- Golang: [warthog618/gpiod](https://github.com/warthog618/gpiod)
- Java: [mattjlewis/diozero](https://github.com/mattjlewis/diozero)
- NodeJS: [sombriks/node-libgpiod](https://github.com/sombriks/node-libgpiod)

Resources
---------

[](#resources)

- [https://elinux.org/images/9/9b/GPIO\_for\_Engineers\_and\_Makers.pdf](https://elinux.org/images/9/9b/GPIO_for_Engineers_and_Makers.pdf)
-
-
-
-

License
-------

[](#license)

This library is licensed under the [PHP License](LICENSE).

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance53

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity16

Early-stage or recently created project

 Bus Factor1

Top contributor holds 70% 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/42b9c9cbc06973a61587667fc811b853f4d71843f35ba2535f3900083e69ab3f?d=identicon)[flavioheleno](/maintainers/flavioheleno)

---

Top Contributors

[![flavioheleno](https://avatars.githubusercontent.com/u/471860?v=4)](https://github.com/flavioheleno "flavioheleno (14 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")

---

Tags

gpiogpio-libraryhacktoberfestphpphp-extension

### Embed Badge

![Health badge](/badges/embedded-php-gpio/health.svg)

```
[![Health](https://phpackages.com/badges/embedded-php-gpio/health.svg)](https://phpackages.com/packages/embedded-php-gpio)
```

PHPackages © 2026

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