gongfangjun/file-manager
Composer 安装命令:
composer require gongfangjun/file-manager
包简介
A file/dir manager for php
关键字:
README 文档
README
A file/dir manager for php
install
add a line to the "require" section in your composer.json,then run the command: composer update
{
"require":{
"gongfangjun/file-manager": "*"
}
}
how to use it in your project
include './vendor/autoload.php';
use FileManager\FileManager;
//scan sub docs in the dir
$fm = new FileManager('/data/upload/');
foreach ($fm->scan() as $doc) {
echo $doc->path,"\n";
}
//scan all the docs in the dir
function scan($path) {
$fm = new FileManager($path);
foreach ($fm->scan() as $doc) {
if ($doc->isDir) {
echo $doc->path,"\n";
scan($doc->path);
} else {
echo $doc->path,"\n";
echo " |- file size : ", $doc->filesize,"\n";
echo " |- last visit time : ", date('Y-m-d H:i:s', $doc->lastVisitTime),"\n";
echo " `- last modify time : ", date('Y-m-d H:i:s', $doc->lastModTime),"\n";
}
}
}
scan('/data/upload/');
//delete a file
$fm = new FileManager('/data/upload/js/inc/bootstrap.js');
$fm->del();
//delete a dir
$fm = new FileManager('/data/upload/js/inc/');
$fm->del();
//read a file
$fm = new FileManager('/data/upload/js/index.js');
$fm->getContent();
//write content to a file
$fm = new FileManager('/data/upload/js/index.js');
$fm->write('var userName = "gongfangjun"');
property of FileManager\Component\Document
click here to see the source code
path
isFile
isDir
isReadable
isWritable
lastVisitTime
lastModTime
filesize
apis
scan a dir
del a file or a dir
write content to a file
get content from a file
create a file
create a dir
统计信息
- 总下载量: 33
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-09-08