Download the PHP package php-io-extensions/gpio without Composer

On this page you can find all versions of the php package php-io-extensions/gpio. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package gpio

GPIO

PHP Zephir Platform

PHP-controllable Linux GPIO extension built with Zephir.

The GPIO extension is an extension for PHP running on supported Linux single-board computers. It allows PHP to use GPIO character devices for sensors, interrupts, LEDs, relays, fans, and similar hardware.

Requirements

Installation

Automatic Installation

PHP PIE is the official PHP extension installer. It builds and enables the extension from the generated C sources in ext/.

Automatic installation requires PIE and the C toolchain for building PHP extensions. Zephir is not required for automatic installation.

Install the FD extension first — GPIO requires raw integer file descriptors that PHP's stream layer cannot provide.

Manual Installation

Manual installation builds the extension from the Zephir source and requires Zephir 0.19+.

Install Zephir if you haven't already:

Use the installer for your target platform:

The installer handles the full workflow: clean → build → copy .so → write 30-gpio.ini into detected conf.d directories → verify php -m → reload php-fpm if present.

To use a specific Zephir binary:

API

All methods are static. File descriptors are plain integers. Use the FD extension to open and close them — PHP's stream-based fopen does not produce the raw integer FDs the kernel ioctls require.

Gpio\GPIOChip

Operations on a GPIO chip file descriptor (e.g. an open /dev/gpiochip0).


getLine(int $fd, int $line, int $flags, int $event_buffer_size = 0, string $consumer = "php-ext-ioctl"): int

Requests a GPIO line and returns a new line file descriptor, or -1 on failure.

Parameter Description
$fd Chip file descriptor
$line Line offset on the chip
$flags GPIO_V2_LINE_FLAG_* bitmask (see linux/gpio.h)
$event_buffer_size Kernel-side edge event buffer size; 0 for default
$consumer Label shown in /sys/kernel/debug/gpio

chipInfo(int $fd): array

Returns chip metadata, or [] on failure.


lineInfo(int $fd, int $offset): array

Returns line metadata, or [] on failure.


lineInfoWatch(int $fd, int $offset): int

Subscribes to line-info change events for $offset on the chip FD. Returns 0 on success, -1 on failure. Read events with lineInfoChanged().


lineInfoUnwatch(int $fd, int $offset): int

Cancels a watch registered with lineInfoWatch(). Returns 0 on success, -1 on failure.


lineInfoChanged(int $fd): array

Blocking read of one gpio_v2_line_info_changed event from the chip FD. Returns [] if no event or on error.


Gpio\GPIOLine

Operations on a line file descriptor returned by GPIOChip::getLine().


getValues(int $fd): int

Returns 1 (HIGH), 0 (LOW), or -1 on failure.


setValues(int $fd, int $value): bool

Drives the line HIGH ($value != 0) or LOW ($value == 0). Returns true on success.


readEdgeEvents(int $fd): array

Blocking read of one edge event from a line configured with EDGE_RISING and/or EDGE_FALLING. Returns [] if no event or on error.


Usage

GPIO v2 flag values for getLine. These map directly to linux/gpio.h — PHP does not define them, so pass the values directly or define your own constants:

Constant Value Description
GPIO_V2_LINE_FLAG_INPUT 0x04 Configure line as input
GPIO_V2_LINE_FLAG_OUTPUT 0x08 Configure line as output
GPIO_V2_LINE_FLAG_EDGE_RISING 0x10 Detect rising edges
GPIO_V2_LINE_FLAG_EDGE_FALLING 0x20 Detect falling edges
GPIO_V2_LINE_FLAG_BIAS_PULL_UP 0x100 Enable pull-up resistor
GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN 0x200 Enable pull-down resistor

Combine with | as needed.


Digital output (LED, relay, fan)

Digital input (button, sensor)

Edge detection (interrupt)

Query chip and line metadata

License

MIT License. See LICENSE.


All versions of gpio with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package php-io-extensions/gpio contains the following files

Loading the files please wait ...