amekusa / phio
Object-oriented filesystem library for PHP
0.2.0
2016-08-29 08:01 UTC
Requires
- php: >=5.3.5
- amekusa/plz: <1.0.0
Requires (Dev)
- apigen/apigen: ^4.1
This package is not auto-updated.
Last update: 2025-01-04 21:19:35 UTC
README
- 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