phellow / filesystem
处理文件系统操作
1.0.0
2014-12-20 14:02 UTC
Requires (Dev)
- phpunit/phpunit: 4.1.*
This package is auto-updated.
Last update: 2024-09-08 22:05:32 UTC
README
将以下依赖添加到您项目的 composer.json 文件中
{ "require": { "phellow/filesystem": "1.*" } }
用法
FilesystemOperator 是处理文件和目录的主要类。您可以将此类的对象添加到依赖注入容器中。
$fs = new \Phellow\Filesystem\FilesystemOperator(); // create a directory if not exists $fs->ensureDir('some/dir'); // copy file or directory $fs->copy('someFile', 'newFile'); $fs->copy('some/dir', 'new/dir'); // get all files/directories of a directory $files = $fs->getFiles('some/dir'); foreach ($files as $file) { if ($file->isFile()) { echo $file->path . ' is a file'; } elseif ($file->isDirectory()) { echo $file->path . ' is a dir'; } elseif ($file->isSymlink()) { echo $file->path . ' is a symlink'; } }
要查看所有可能的选择,您可以查看 tests/ 下的单元测试。
许可证
MIT 许可证。