yalesov / file-system-manager
一系列文件和目录管理功能。
v2.0.6
2016-07-06 12:20 UTC
Requires
- php: >=5.3.3
- yalesov/arg-validator: 2.*
Requires (Dev)
README
收集了PHP核心中不存在的常用文件和目录管理功能。
安装
{ "require": { "yalesov/file-system-manager": "2.*" } }
用法
递归遍历目录foo
,列出所有文件(子文件最后)
use \Yalesov\FileSystemManager\FileSystemManager; foreach (FileSystemManager::fileIterator('foo') as $file) { echo $file; // /path/to/file }
递归遍历目录foo
,列出所有目录(子目录首先)
use \Yalesov\FileSystemManager\FileSystemManager; foreach (FileSystemManager::dirIterator('foo') as $dir) { echo $dir; // /path/to/child/dir }
递归rmdir:删除目录foo
及其所有子目录和文件
use \Yalesov\FileSystemManager\FileSystemManager; FileSystemManager::rrmdir('foo');
递归copy:将目录foo
复制到bar
,包括所有子目录和文件
警告:此函数会覆盖现有文件
use \Yalesov\FileSystemManager\FileSystemManager; FileSystemManager::rcopy('foo', 'bar');
rcopy
会复制到已存在的目录中。默认情况下,它将创建不存在目录,权限为0755
。您可以通过指定第三个参数来更改此设置
FileSystemManager::rcopy('foo', 'bar', 0777);
递归chmod:将目录foo
的权限设置为0755
,包括所有子目录和文件
use \Yalesov\FileSystemManager\FileSystemManager; FileSystemManager::rchmod('foo', 0755);
递归chown:将目录foo
的所有者设置为www-data
,包括所有子目录和文件
use \Yalesov\FileSystemManager\FileSystemManager; FileSystemManager::rchown('foo', 'www-data');
递归chgrp:将目录foo
的组设置为www-data
,包括所有子目录和文件
use \Yalesov\FileSystemManager\FileSystemManager; FileSystemManager::rchown('foo', 'www-data');