https://github.com/pmvc-plugin/file_info
PMVC file information plugin
https://github.com/pmvc-plugin/file_info
Last synced: about 1 month ago
JSON representation
PMVC file information plugin
- Host: GitHub
- URL: https://github.com/pmvc-plugin/file_info
- Owner: pmvc-plugin
- Created: 2016-04-04T16:55:07.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2018-09-18T20:37:28.000Z (over 7 years ago)
- Last Synced: 2025-03-21T21:44:43.737Z (about 1 year ago)
- Language: PHP
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://packagist.org/packages/pmvc-plugin/file_info)
[](https://packagist.org/packages/pmvc-plugin/file_info)
[](https://travis-ci.org/pmvc-plugin/file_info)
[](https://packagist.org/packages/pmvc-plugin/file_info)
[](https://packagist.org/packages/pmvc-plugin/file_info)
File Information Plugin
===============
## Table of Contents
- [Introduction](#introduction)
- [Install with Composer](#install-with-composer)
- [How to use](#how-to-use)
## 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()
```