2017 © Pedro Peláez
 

library file-manager

A file/dir manager for php

image

gongfangjun/file-manager

A file/dir manager for php

  • Friday, September 9, 2016
  • by gongfangjun
  • Repository
  • 0 Watchers
  • 1 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

file-manager

A file/dir manager for php, (*1)

install

add a line to the "require" section in your composer.json,then run the command: composer update, (*2)

{
    "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, (*3)

path, (*4)

isFile, (*5)

isDir, (*6)

isReadable, (*7)

isWritable, (*8)

lastVisitTime, (*9)

lastModTime, (*10)

filesize, (*11)

apis

scan(), (*12)

   scan a dir, (*13)

del(), (*14)

   del a file or a dir, (*15)

write(), (*16)

   write content to a file, (*17)

getContent(), (*18)

   get content from a file, (*19)

createFile(), (*20)

   create a file, (*21)

createDir(), (*22)

   create a dir, (*23)

The Versions

09/09 2016

dev-master

9999999-dev

A file/dir manager for php

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Avatar gongfangjun

file-manager

09/09 2016

dev-develop

dev-develop

A file/dir manager for php

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Avatar gongfangjun

file-manager

09/09 2016

1.0.3

1.0.3.0

A file/dir manager for php

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Avatar gongfangjun

file-manager

08/09 2016

1.0.2

1.0.2.0

A file/dir manager for php

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Avatar gongfangjun

file-manager

08/09 2016

1.0.1

1.0.1.0

A file/dir manager for php

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Avatar gongfangjun

file-manager