scrapyard-io/fd
最新稳定版本:0.3.0
Composer 安装命令:
composer require scrapyard-io/fd
包简介
FD Section of The ScrapyardIO Framework
关键字:
README 文档
README
dept-of-scrapyard-robotics/fd — file descriptor module for the ScrapyardIO Framework.
Provides a lightweight PHP layer over the ext-fd extension. It exposes simple helper functions for opening, closing, reading, and writing raw file descriptors, plus reusable traits, attributes, and enums for higher-level ScrapyardIO packages.
Requirements
- PHP ^8.3
ext-fd0.1.0 (Zephir extension — see DeptOfScrapyardRobotics/FD for build & install instructions)dept-of-scrapyard-robotics/support^0.3.0- A UNIX-like environment supported by
ext-fd
Installation
composer require dept-of-scrapyard-robotics/fd
Quick Start
Opening and closing a device
use ScrapyardIO\FD\Enums\FileControlFlag; $fd = fd_open('/dev/i2c-1', FileControlFlag::O_RDWR->value); if ($fd < 0) { throw new RuntimeException('Unable to open device'); } $bytes = fd_read($fd, 2); fd_close($fd);
Writing to a descriptor
use ScrapyardIO\FD\Enums\FileControlFlag; $fd = fd_open('/dev/ttyUSB0', FileControlFlag::O_WRONLY->value); fd_write($fd, "\x3A", 1); fd_close($fd);
API Reference
Helper Functions
Autoloaded global helper functions that forward directly to the ext-fd extension.
| Function | Returns | Description |
|---|---|---|
fd_open(string $device_path, int $flags) |
int |
Open a file or device and return its file descriptor |
fd_close(int $fd) |
int |
Close an open file descriptor |
fd_read(int $fd, int $bytes_to_read) |
string |
Read up to the requested number of bytes |
fd_write(int $fd, string $data, int $bytes_to_write) |
int |
Write bytes to the descriptor |
fd_add_flags(int $fd, int $flags) |
int |
Add file status flags with fcntl() |
FileControlFlag
Enum of common fcntl.h/POSIX open flags.
| Case | Value | Description |
|---|---|---|
O_RDONLY |
0 |
Open read-only |
O_WRONLY |
1 |
Open write-only |
O_RDWR |
2 |
Open read/write |
O_APPEND |
1024 |
Append on each write |
O_ASYNC |
8192 |
Enable signal-driven I/O |
O_CLOEXEC |
524288 |
Close on exec() |
O_CREAT |
64 |
Create file if it does not exist |
O_DIRECT |
16384 |
Minimize cache effects |
O_DIRECTORY |
65536 |
Fail if path is not a directory |
O_DSYNC |
4096 |
Synchronized writes |
O_EXCL |
128 |
Exclusive create |
O_NOATIME |
262144 |
Do not update access time |
O_NOCTTY |
256 |
Do not assign controlling terminal |
O_NOFOLLOW |
131072 |
Fail on symlink |
O_NONBLOCK |
2048 |
Non-blocking I/O |
O_PATH |
2097152 |
Obtain path-only descriptor |
O_SYNC |
1052672 |
Fully synchronized I/O |
O_TMPFILE |
4259840 |
Create unnamed temporary file |
O_TRUNC |
512 |
Truncate existing file |
FileDescriptors
Reusable trait for ScrapyardIO classes that open their descriptor from annotated properties.
use ScrapyardIO\FD\Attributes\FDFlags; use ScrapyardIO\FD\Attributes\FilePath; use ScrapyardIO\FD\Concerns\FileDescriptors; use ScrapyardIO\FD\Enums\FileControlFlag; class Device { use FileDescriptors; #[FilePath] public readonly string $devicePath; #[FDFlags] public readonly int $flags; public function __construct() { $this->devicePath = '/dev/i2c-1'; $this->flags = FileControlFlag::O_RDWR->value; $fd = $this->fOpen(); } }
| Method | Returns | Description |
|---|---|---|
fOpen() |
int |
Reflects the annotated path and flags properties, then opens the descriptor |
Attributes
Marker attributes used by FileDescriptors.
| Attribute | Applied To | Description |
|---|---|---|
#[FilePath] |
Property | Marks the property containing the device path |
#[FDFlags] |
Property | Marks the property containing the open flags |
#[FileDescriptor] |
Property | Marks the property that stores the resulting descriptor |
License
MIT — © Angel Gonzalez / Project Saturn Studios
scrapyard-io/fd 适用场景与选型建议
scrapyard-io/fd 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「scrapyard-io」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 scrapyard-io/fd 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 scrapyard-io/fd 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 scrapyard-io/fd 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
High-performance, opinionated PHP 8 web framework with O(1) routing, parallel async MySQL, type-safe asset bridge, and React-island frontend
Drive Barometric Pressure sensors from Bosch Sensortec over I2C with PHP
Drive VEML7000 lux sensors over I2C with PHP
Drive BH1750 ALS sensors over I2C with PHP
The skeleton application for the Geoffrey agent framework.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 24
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-17