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

On this page you can find all versions of the php package php-io-extensions/uart. 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 uart

UART

PHP Zephir Platform

PHP-controllable UART extension built with Zephir.

The UART extension gives PHP direct control over serial ports on Linux and macOS — configuring baud rate, framing, parity, flow control, and modem control lines, then performing raw reads and writes. Useful for microcontrollers, GPS modules, RS-232/RS-485 adapters, and any other device connected over a serial UART.

Requirements

macOS note: Standard baud rates up to 230400 are available on all platforms. Linux-specific high rates (460800, 921600, and above) are only available on Linux.

Installation

Install Zephir if you haven't already:

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

Then clone and build this extension:

The install script handles the full workflow: clean → build → copy .so → write 30-uart.ini into all 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 that termios requires.


Uart\UARTConfig

Terminal attribute configuration on a UART file descriptor. All setters call tcsetattr(TCSANOW) internally — changes take effect immediately.


setRaw(int $fd): int

Puts the terminal into raw mode: no input processing, no echo, no signal generation. Equivalent to cfmakeraw() followed by VMIN=1, VTIME=0. This is the correct starting point for binary protocols. Returns 0 on success, -1 on failure.


setBaudRate(int $fd, int $baud): int

Sets both input and output baud rate. Supported values on all platforms: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400. Linux-only: 460800, 500000, 576000, 921600, 1000000, 1152000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000. Returns 0 on success, -1 on unrecognised rate or failure.


setDataBits(int $fd, int $bits): int

Sets data bits per character: 5, 6, 7, or 8. Returns 0 on success, -1 on invalid value or failure.


setStopBits(int $fd, int $bits): int

Sets stop bits: 1 or 2. Returns 0 on success, -1 on invalid value or failure.


setParity(int $fd, int $parity): int

Sets parity mode:

Value Mode
0 None
1 Even
2 Odd

Returns 0 on success, -1 on invalid value or failure.


setFlowControl(int $fd, int $flow): int

Sets flow control mode:

Value Mode
0 None
1 Hardware (RTS/CTS via CRTSCTS)
2 Software (XON/XOFF via IXON/IXOFF)

Returns 0 on success, -1 on invalid value or failure.


getAttributes(int $fd): array

Reads the full termios struct and returns it as an associative array. Returns [] on failure.

Key Type Description
iflag int Input mode flags (c_iflag)
oflag int Output mode flags (c_oflag)
cflag int Control mode flags (c_cflag)
lflag int Local mode flags (c_lflag)
ispeed int Input baud rate constant
ospeed int Output baud rate constant
cc array Control characters array, indexed 0–NCCS-1

setAttributes(int $fd, array $attrs): int

Applies terminal attributes from an associative array via tcsetattr(TCSANOW). Accepts the same keys returned by getAttributes(). Partial updates are supported — only keys present in $attrs are applied. Returns 0 on success, -1 on failure.


Uart\UARTUse

Data transfer and line control on a UART file descriptor.


read(int $fd, int $bytes_to_read): string

Reads up to $bytes_to_read bytes from the device. Blocks until at least one byte is available (when in raw mode with VMIN=1). Returns the bytes as a binary string, or "" on error.


write(int $fd, string $data, int $bytes_to_write): int

Writes $bytes_to_write bytes to the device. Returns the number of bytes written, or -1 on failure.


drain(int $fd): int

Blocks until all data written to $fd has been physically transmitted. Returns 0 on success, -1 on failure.


flush(int $fd, int $queue_selector): int

Discards queued data that has not yet been read or transmitted.

Value queue_selector constant Effect
0 TCIFLUSH Discard received but unread data
1 TCOFLUSH Discard written but untransmitted data
2 TCIOFLUSH Discard both

Returns 0 on success, -1 on failure.


flow(int $fd, int $action): int

Suspends or resumes data flow.

Value action constant Effect
0 TCOOFF Suspend output
1 TCOON Resume output
2 TCIOFF Send STOP character, suspend input
3 TCION Send START character, resume input

Returns 0 on success, -1 on failure.


getModemBits(int $fd): int

Returns the current modem control line status bitmask via TIOCMGET, or -1 on failure. Compare against TIOCM_* values:

Constant Value Line
TIOCM_LE 0x001 Line Enable
TIOCM_DTR 0x002 Data Terminal Ready
TIOCM_RTS 0x004 Request To Send
TIOCM_CTS 0x020 Clear To Send
TIOCM_CAR 0x040 Carrier Detect
TIOCM_RNG 0x080 Ring Indicator
TIOCM_DSR 0x100 Data Set Ready

setModemBits(int $fd, int $bits): int

Replaces the full modem control line state via TIOCMSET. Returns 0 on success, -1 on failure.


setBits(int $fd, int $bits): int

Asserts (raises) specific modem control lines without affecting others, via TIOCMBIS. Returns 0 on success, -1 on failure.


clearBits(int $fd, int $bits): int

Deasserts (lowers) specific modem control lines without affecting others, via TIOCMBIC. Returns 0 on success, -1 on failure.


Usage


Basic send/receive at 115200 8N1


Hardware flow control (RTS/CTS)


Flush and inspect attributes


Assert DTR, check CTS


License

Copyright © Project Saturn Studios, LLC. All rights reserved.


All versions of uart 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/uart contains the following files

Loading the files please wait ...