2017 © Pedro Peláez
 

library directory-iterator-plus

A simple extension of the PHP \DirectoryIterator class

image

dcarbone/directory-iterator-plus

A simple extension of the PHP \DirectoryIterator class

  • Friday, February 2, 2018
  • by dcarbone
  • Repository
  • 1 Watchers
  • 0 Stars
  • 33 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 3 % Grown

The README.md

directory-iterator-plus

A simple extension of the PHP \DirectoryIterator class, (*1)

Build Status: Build Status, (*2)

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., (*3)

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

This class met that need., (*5)

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., (*6)

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, (*7)

File and Directory Counting

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

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

Searching

There are several options available to you:, (*10)

  • 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., (*11)

File Pagination

There are currently two Pagination methods available:, (*12)

  • 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., (*13)

The $search term again uses the PHP stripos method to determine matches., (*14)

The primary difference between these two methods is the contents of the returned array., (*15)

paginateFileNames(), (*16)

This method will return an array of file names that match the input criteria, (*17)

paginateFiles(), (*18)

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

Comments and Suggestions

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

The Versions

02/02 2018

dev-master

9999999-dev https://github.com/dcarbone/directory-iterator-plus

A simple extension of the PHP \DirectoryIterator class

  Sources   Download

GPLv3 MPL-2.0

The Requires

  • php >=5.4

 

The Development Requires

by Daniel Carbone

php search directory directory search file pagination directory pagination directoryiterator directory iterator file search

02/02 2018

0.3.0

0.3.0.0 https://github.com/dcarbone/directory-iterator-plus

A simple extension of the PHP \DirectoryIterator class

  Sources   Download

MPL-2.0

The Requires

  • php >=5.4

 

The Development Requires

by Daniel Carbone

php search directory directory search file pagination directory pagination directoryiterator directory iterator file search

19/12 2014

0.2.3

0.2.3.0 https://github.com/dcarbone/directory-iterator-plus

A simple extension of the PHP \DirectoryIterator class

  Sources   Download

GPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

by Daniel Carbone

php search directory directory search file pagination directory pagination directoryiterator directory iterator file search

19/12 2014

0.2.2

0.2.2.0 https://github.com/dcarbone/directory-iterator-plus

A simple extension of the PHP \DirectoryIterator class

  Sources   Download

GPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

by Daniel Carbone

php search directory directory search file pagination directory pagination directoryiterator directory iterator file search

17/12 2014

0.2.1

0.2.1.0 https://github.com/dcarbone/directory-iterator-plus

A simple extension of the PHP \DirectoryIterator class

  Sources   Download

GPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

by Daniel Carbone

php search directory directory search file pagination directory pagination directoryiterator directory iterator file search

17/12 2014

0.2.0

0.2.0.0 https://github.com/dcarbone/directory-iterator-plus

A simple extension of the PHP \DirectoryIterator class

  Sources   Download

GPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

by Daniel Carbone

php search directory directory search file pagination directory pagination directoryiterator directory iterator file search

11/12 2014

0.1.2

0.1.2.0 https://github.com/dcarbone/directory-iterator-plus

A simple extension of the PHP \DirectoryIterator class

  Sources   Download

GPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

by Daniel Carbone

php search directory directory search file pagination directory pagination directoryiterator directory iterator file search

17/08 2014

0.1.1

0.1.1.0 https://github.com/dcarbone/directory-iterator-plus

A simple extension of the PHP \DirectoryIterator class

  Sources   Download

GPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

by Daniel Carbone

php search directory directory search file pagination directory pagination directoryiterator directory iterator file search

14/08 2014

0.1.0

0.1.0.0 https://github.com/dcarbone/directory-iterator-plus

A simple extension of the PHP \DirectoryIterator class

  Sources   Download

GPLv3

The Requires

  • php >=5.3.3

 

The Development Requires

by Daniel Carbone

php search directory directory search file pagination directory pagination directoryiterator directory iterator file search