承接 dcarbone/directory-iterator-plus 相关项目开发

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

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

dcarbone/directory-iterator-plus

Composer 安装命令:

composer require dcarbone/directory-iterator-plus

包简介

A simple extension of the PHP \DirectoryIterator class

README 文档

README

A simple extension of the PHP \DirectoryIterator class

Build Status: Build Status

Installation in your Composer App

{
    "require": {
      "dcarbone/directory-iterator-plus" : "@stable"
    }
}

Concept

I had a need to be able to, relatively quickly, create a web interface which allowed the navigation of a directory of thousands of files.

I did not want to glob() my way through them, and I wanted a simple way to paginate and search through them.

This class met that need.

Usage

This class is an extension of the base PHP class DirectoryIterator and as such has all the same methods available, and to a great extent it's functionality is unchanged.

New Methods

I have provided several custom methods, most of which revolve around either getting a subset of files or determining the existence of a file within a directory

File and Directory Counting

You may retrieve these values after instantiation by calling getFileCount() or getDirectoryCount() methods.

I used to do some exec nonsense, but now I just be lazy and use glob.

Searching

There are several options available to you:

  • Determine existence by exact file / directory name
    • containsFile($file)
    • containsDirectory($directory)
  • Determine existence by string search term
    • containsFileLike($string[, $caseInsensitive = false])
    • containsDirectoryLike($string[, $caseInsensitive = false])
  • Get Count of files / directories by search term
    • getFileCountLike($string)
    • getDirectoryCountLike($string)

Each of the "Like" methods utilize PHP's stripos function to determine if the passed value is contained wholly somewhere inside of the filename of a given file / directory.

File Pagination

There are currently two Pagination methods available:

  • paginateFileNames([$offset 0[, $limit = 25[, $search = null]]])
  • paginateFiles([$offset 0[, $limit = 25[, $search = null]]])

These methods are designed to operate similar to any other pagination code used against a database.

The $search term again uses the PHP stripos method to determine matches.

The primary difference between these two methods is the contents of the returned array.

paginateFileNames()

This method will return an array of file names that match the input criteria

paginateFiles()

This method will return an array of \DCarbone\DirectoryIteratorPlus objects, each representing an individual file.

Comments and Suggestions

If you find this library useful and have an idea of how it can be made better, please let me know!

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MPL-2.0
  • 更新时间: 2014-08-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固