承接 mcoste/directory-files-stream-wrapper 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

mcoste/directory-files-stream-wrapper

Composer 安装命令:

composer require mcoste/directory-files-stream-wrapper

包简介

A stream wrapper for PHP that allow to read from multiple files with one resource.

README 文档

README

Allow to read all files of a directory with a single resource object.

Install

composer require mcoste/directory-files-stream-wrapper

Initialization

Before being able to use this stream wrapper, you have to register it. To do so, you have 2 ways.

The easy way

You can use the PHP stream_wrapper_register() function:

stream_wrapper_register('protocol', DirectoryFilesStreamWrapper::class);

Replace 'protocol' by whatever valid string you want. See the RFC 2396 (section 3.1: Scheme Component) for more details. You can simply use DirectoryFilesStreamWrapper::DEFAULT_PROTOCOL_NAME if you want.

The very easy way

An easier way is to call the static method DirectoryFilesStreamWrapper::register(). And that's it, you're good to go.

This method takes an optional parameter to specify the protocol name you want. By default, it uses DirectoryFilesStreamWrapper::DEFAULT_PROTOCOL_NAME.

Usage

With the registration completed, all you have to do is open a directory like so :

$resource = fopen('protocol://path/to/my/directory', 'r');

'protocol' must be replaced by the protocol name you have chosen ('directory-files' if you used DirectoryFilesStream::register() without parameters)

You can now use the resource as any other. For exemple :

$line = fgets($resource);

The files to be read are sorted by their names using the natural order, as defined by the PHP function natsort().

Limitations

Read only

This stream wrapper does not allow any other mode than 'r'. You can pass whatever mode you want to fopen(), 'r' will always be used. This limitation is needed because 'r' is the only mode that makes sense in the context of this wrapper.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-03-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固