pmvc-plugin/file_info

PMVC Plugin for File information

0.1.5 2018-09-18 20:36 UTC

This package is auto-updated.

Last update: 2024-11-12 04:24:44 UTC


README

Latest Stable Version Latest Unstable Version Build Status License Total Downloads

File Information Plugin

Table of Contents

Introduction

This is a file information library, could help you get file size or time.

Install with Composer

1. Download composer

2. Install by composer.json or use command-line directly

2.1 Install by composer.json

  • vim composer.json
{
    "require": {
        "pmvc-plugin/file_info": "dev-master"
    }
}
  • php composer.phar install

2.2 Or use composer command-line

  • php composer.phar require pmvc-plugin/file_info

How to use

Use Path only (file don't need exists)

include_once('vendor/autoload.php');
PMVC\Load::plug();
$fileInfo = \PMVC\plug('file_info');
$fileInfo->path('/abc/abc.php')->getExt(); // will return "php"

Path functions

  • getExt()
  • getContentType()
    • Return content-type, such as "image/png"

Use with file (file need exists)

include_once('vendor/autoload.php');
PMVC\Load::plug();
$fileInfo = \PMVC\plug('file_info');
$fileInfo->file('/abc/abc.php')->getExt(); // will return "php"

File functions (extends all Path functions)

  • realPath()
    • Get realpath
  • getSize()
   $fileInfo = \PMVC\plug('file_info');
   $size = $fileInfo->file('/abc/abc.php')->getSize();
   echo $size; //transafer to readable format automatically by __tostring()
  • getTime()
   $fileInfo = \PMVC\plug('file_info');
   $accessTime = $fileInfo->file('/abc/abc.php')->getTime()->atime();
   echo $accessTime; //transafer to readable format automatically by __tostring()