kedrigern/phpio
Composer 安装命令:
composer require kedrigern/phpio
包简介
PHP class for batch file processing. You can read, write, delete, move. All in pretty object.
README 文档
README
Contains class for manipulation with files. It is simple wrapper over internal functions, but in pretty object form.
Examples
We suppose:
$files = new \Kedrigern\phpIO\Files();
Cat all *.txt files and after delete them:
$cat = function($file) { echo "Filename: $file \n"; echo file_get_contents($file); echo "\n"; }; $files->dir('*.txt')->call($cat)->delete();
Write "Some data" to all *.txt files and after move them to the directory archive. If files are not writable throw exception with description of problem (exact file, privileges etc.)
$fill = function($file) { file_put_contents($file, "Some data."); }; $files->dir('*.txt')->writeable()->call($fill)->move('archive', true);
Sum numbers from files (with num sufix):
$parseIntFromFile = function($file) { return intval(file_get_contents($file)); }; $postSum = function($results) { return array_sum($results); }; $files->dir('*.num')->call($parseIntFromFile, $postSum, $log); // now $log['post'] contains sum
Install and tests
composer install
vendor/bin/tester -c test/ test/
Authors and contact
统计信息
- 总下载量: 38
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 54
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2014-07-27