ronanguilloux/php-gpio
PHP-GPIO provides an object-oriented interface to Raspberry Pi GPIO pins, letting PHP applications read inputs, set outputs, and configure pin modes. Useful for prototyping and controlling LEDs, relays, sensors, and other hardware from PHP.
/sys/class/gpio/export, direction, value) in a small PHP API, so a feature like toggle a relay, read a door sensor, blink a status LED, or power-cycle a fan can be built inside an existing Laravel codebase in an afternoon instead of standing up a new service in another language.gpiozero/lgpio, a libgpiod command wrapper, or an MQTT/ESPHome relay board) behind a REST or MQTT contract. The package makes the "PHP does it directly" option concrete and cheap to falsify.Consider it when:
Look elsewhere when:
libgpiod/character-device access instead, which this library does not speak.gpio group or run as root, and a compromised web app can then actuate physical hardware. That is a real threat-model conversation, not a footnote.gpiozero/lgpio sidecar behind HTTP or MQTT, a libgpiod CLI wrapper invoked from Laravel, or off-the-shelf networked relay/IO modules — all give you a cleaner contract and a live upstream.For executives (one paragraph): This is a free, MIT-licensed, small PHP library that lets our existing Laravel application drive the GPIO pins on a Raspberry Pi — meaning we can demonstrate a hardware-connected feature (a relay-controlled device, a sensor-backed dashboard, a locked cabinet or kiosk) using the team and stack we already have, with zero license cost and no vendor commitment. That makes it an excellent two-to-four-week feasibility spike, not a platform choice: the library has had no release since 2013 and relies on a Linux interface that current Raspberry Pi operating systems are phasing out, so it carries maintenance and security risk and would need replacing before anything ships to customers. Recommendation: approve a time-boxed spike to validate demand and produce a working demo, with a pre-agreed exit criterion — migrate to a small dedicated hardware service (or a maintained libgpiod-based agent) before any production commitment.
For engineering: A thin, dependency-free wrapper over sysfs GPIO — no interfaces, no DI, no events, no test seams, PHP 5-era style. Wrap it behind your own GpioDevice contract from day one so the spike's code survives the eventual swap. Operational notes: the PHP-FPM user needs gpio group membership and udev rules (do not run the web server as root), there is no concurrency or debounce support, and sysfs edge detection is poll-based and unreliable — assume anything needing sub-100ms timing is out of scope. Vendor the source rather than relying on a package that hasn't shipped in twelve years.
How can I help you explore Laravel packages today?