pmvc-plugin / file_info
PMVC Plugin for File information
Installs: 1 130
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- pmvc/pmvc: *
This package is auto-updated.
Last update: 2024-12-12 04:33:34 UTC
README
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
- mkdir test_folder
- curl -sS https://getcomposer.org/installer | php
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()