aternos/io 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aternos/io

Composer 安装命令:

composer require aternos/io

包简介

PHP library for IO operations

README 文档

README

PHP library for IO operations.

The main goal of this library is to abstract IO operations to make different kind of IO elements, e.g. files and streams, interchangeable and allow writing code that doesn't depend on the filesystem, but feature interfaces that can be implemented for any kind of IO backend, e.g. network based storages.

Installation

composer require aternos/io

Basic Usage

use Aternos\IO\System\File\File;
use Aternos\IO\System\Directory\Directory;

$file = new File("path/to/file.txt");
$file->create();
$file->write("Hello World!");
$file->setPosition(0);
echo $file->read($file->getSize());
$file->delete();

$directory = new Directory("path/to/directory");
foreach ($directory->getChildrenRecursive() as $child) {
    echo $child->getPath() . PHP_EOL;
}
$directory->delete();

IO Elements

Name Class Description
File Aternos\IO\System\File\File Regular filesystem file
TempDiskFile Aternos\IO\System\File\TempDiskFile Temporary disk file, created and deleted automatically
TempMemoryFile Aternos\IO\System\File\TempMemoryFile Temporary file in memory
TempMemoryDiskFile Aternos\IO\System\File\TempMemoryDiskFile Temporary file in memory, moved to disk when size exceeds a threshold
Directory Aternos\IO\System\Directory\Directory Regular filesystem directory
TempDirectory Aternos\IO\System\Directory\TempDirectory Temporary directory, created and deleted automatically
FilteredDirectory Aternos\IO\System\Directory\FilteredDirectory Directory that filters its children
Link Aternos\IO\System\Link\Link Generic filesystem link
FileLink Aternos\IO\System\Link\FileLink Filesystem link to a file, can be used like a file
DirectoryLink Aternos\IO\System\Link\DirectoryLink Filesystem link to a directory, can be used like a directory
SocketStream Aternos\IO\System\Socket\Stream\SocketStream Stream for reading from and writing to sockets
SocketReadStream Aternos\IO\System\Socket\Stream\SocketReadStream Stream for read only sockets
SocketWriteStream Aternos\IO\System\Socket\Stream\SocketWriteStream Stream for write only sockets

You can get the correct IO element from a path using FilesystemElement::getIOElementFromPath().

use Aternos\IO\System\FilesystemElement;

$element = FilesystemElement::getIOElementFromPath("path/to/element");

Interfaces

You can and should use the provided interfaces when writing your code to make it more flexible and interchangeable.

The basic interface for all IO elements is Aternos\IO\Interfaces\IOElementInterface.

Feature Interfaces

The feature interfaces define specific features that an IO element can have, e.g. reading or writing. You should limit the required type in your code to the specific features that you need. All feature interfaces are listed here: src/Interfaces/Features.

Example

use Aternos\IO\Interfaces\Features\ReadInterface;
use Aternos\IO\Interfaces\Features\GetSizeInterface;

function readEntireFile(ReadInterface&GetSizeInterface $file): string {
    return $file->read($file->getSize());
}

Type Interfaces

For convenience, this library also provides type interfaces that combine multiple feature interfaces for common IO elements. All type interfaces are listed here: src/Interfaces/Types.

aternos/io 适用场景与选型建议

aternos/io 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 43.67k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 11 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 aternos/io 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 aternos/io 我们能提供哪些服务?
定制开发 / 二次开发

基于 aternos/io 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 43.67k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-14