2017 © Pedro Peláez
 

library filelist

File Listing helper class

image

jc21/filelist

File Listing helper class

  • Monday, January 29, 2018
  • by jc21
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,102 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

File Listing helper class for PHP

  • List files from a directory
  • Filter for only directories, files or file types
  • Sort and limit the listing items

Installing via Composer

# Install Composer
curl -sS https://getcomposer.org/installer | php

Next, run the Composer command to install the latest stable version:, (*1)

composer.phar require jc21/filelist

After installing, you need to require Composer's autoloader:, (*2)

require 'vendor/autoload.php';

Using

use jc21\FileList;

$fileList = new FileList;

$items = $fileList->get('/path/to/files');

// Use the items array
print '

';
foreach ($items as $item) {
    if ($item[FileList::KEY_TYPE] == FileList::TYPE_DIR) {
        print 'd' . "\t" . $item[FileList::KEY_NAME] . PHP_EOL;
    } else {
        print 'f' . "\t" . $item[FileList::KEY_NAME] . "\t" . $item[FileList::KEY_SIZE] . "\t" . date('Y-m-d', $item[FileList::KEY_DATE]) . PHP_EOL;
    }
}
print '
';

Or to get only directories:, (*3)

$items = $fileList->get('/path/to/files', FileList::TYPE_DIR);

Or only files:, (*4)

$items = $fileList->get('/path/to/files', FileList::TYPE_FILE);

Or only files of a certain extension:, (*5)

$extensions = array('jpg', 'png', 'jpeg', 'gif');
$items      = $fileList->get('/path/to/files', FileList::TYPE_DIR, FileList::KEY_NAME, FileList::ASC, null, $extensions);

Order by the Size descending:, (*6)

$items = $fileList->get('/path/to/files', FileList::TYPE_DIR, FileList::KEY_SIZE, FileList::DESC);

The Versions

29/01 2018

dev-master

9999999-dev https://github.com/jc21/filelist

File Listing helper class

  Sources   Download

BSD BSD-1-Clause

The Requires

  • php >=5.3.0

 

The Development Requires

by Jamie Curnow

file dir listing

19/08 2015

1.1

1.1.0.0 https://github.com/jc21/filelist

File Listing helper class

  Sources   Download

BSD

The Requires

  • php >=5.3.0

 

The Development Requires

by Jamie Curnow

file dir listing

11/06 2015

1.0

1.0.0.0 https://github.com/jc21/filelist

File Listing helper class

  Sources   Download

BSD

The Requires

  • php >=5.3.0

 

by Jamie Curnow

file dir listing