PhiO: Object-oriented filesystem library for PHP
  • Namespace
  • Class
  • Tree
  • Todo

Namespaces

  • amekusa
    • phio
  • PHP

Classes

  • amekusa\phio\Directory
  • amekusa\phio\File
  • amekusa\phio\FilePool
  • amekusa\phio\Filter
  • amekusa\phio\Perms
  • amekusa\phio\RegexFilter
  • amekusa\phio\RegFile

Exceptions

  • amekusa\phio\ErrorException
  • amekusa\phio\IOException

PhiO: Object-oriented filesystem library for PHP

  • Consistent & clear API
  • Encapsulates bothersome
  • Less typing, but also readable
  • Well tested & documented
    📘 See the complete documentation

Install

Install via Composer.

composer require amekusa/phio

Examples

Assumed directory structure:

/
└── srv
    └── http
        ├── favicon.svg
        ├── index.html
        ├── script.js
        └── style.css

Iterate over files in a directory

use amekusa\phio\Directory;

$dir = new Directory('/srv/http');
foreach ($dir as $file) {
    echo $file->getPath() . "\n";
}

This code results:

/srv/http/favicon.svg
/srv/http/index.html
/srv/http/script.js
/srv/http/style.css

Filter files

use amekusa\phio\Directory;
use amekusa\phio\Filter;

$dir = new Directory('/srv/http');
$dir->addFilter(new Filter('s*.*s'));

foreach ($dir as $file) {
    echo $file->getPath() . "\n";
}

This code results:

/srv/http/script.js
/srv/http/style.css

You can also use regular expression like this:

use amekusa\phio\Directory;
use amekusa\phio\RegexFilter;

$dir = new Directory('/srv/http');
$dir->addFilter(new RegexFilter('/\.[a-z]{3}$/'));

foreach ($dir as $file) {
    echo $file->getPath() . "\n";
}

This code results:

/srv/http/favicon.svg
/srv/http/style.css
PhiO: Object-oriented filesystem library for PHP API documentation generated by ApiGen