gmi/toolkit-fileinfo 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gmi/toolkit-fileinfo

Composer 安装命令:

composer require gmi/toolkit-fileinfo

包简介

File information component

README 文档

README

This library provides features to read file information.

It provides an abstraction layer above SplFileInfo for consistent behavior and easier usage.

  • Ability to retrieve the file name without its extension
  • Human-readable file sizes
  • Usage of DateTime objects instead of Unix timestamps
  • Ability to retrieve the file owner/group (via posix_* functions)
  • Human-readable permissions

File information is read during construction of the FileInfo instance or when FileInfo::reload() is called.

For easier dependency injection in projects, a simple FileInfoFactory is provided.

The current build status and code analysis can be found here:

Requirements

  • PHP 5.6.0 or higher
  • PHP mbstring extension
  • PHP posix extension

Installation

The recommended way to install toolkit-fileinfo is via composer.

"require": {
    "gmi/toolkit-fileinfo": "1.1.*"
}

Usage examples

use Gmi\Toolkit\Fileinfo\FileInfo;

$fileInfo = new FileInfo('/path/to/awesome.pdf');

/**
 * Get information about file path:
 * @see Gmi\Toolkit\Fileinfo\Part\PathInfo
 */

$fileInfo->path()->getPath();
// '/path/to'

$fileInfo->path()->getFilename();
// 'awesome.pdf'

$fileInfo->path()->getFilenameWithoutExtension();
// 'awesome'

$fileInfo->path()->getExtension();
// 'pdf'

/**
 * Get information about file size:
 * @see Gmi\Toolkit\Fileinfo\Part\SizeInfo
 */

$fileInfo->size()->getSize();
// 34703

$fileInfo->size()->getSizeFormatted();
// '33.89 KiB'

/**
 * Get information about file dates:
 * @see Gmi\Toolkit\Fileinfo\Part\DateInfo
 */

$fileInfo->date()->getLastAccessed();
// object(DateTime)

$fileInfo->date()->getLastModified();
// object(DateTime)

/**
 * Get information about file permissions:
 * @see Gmi\Toolkit\Fileinfo\Part\PermissionInfo
 */

$fileInfo->perm()->getOwner();
// 0

$fileInfo->perm()->getOwnerName();
// 'root'

$fileInfo->perm()->getPermsFormatted();
// 'rw-r--r--'

/**
 * Get information about file type:
 * @see Gmi\Toolkit\Fileinfo\Part\TypeInfo
 */

$fileInfo->type()->getMimeType();
// 'application/pdf'

/**
 * Reload file information:
 */
$fileInfo->reload();

Tests

The test suite can be run with vendor/bin/phpunit tests. Tests are insulated by using a temporary directory per test.

统计信息

  • 总下载量: 38
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0-only
  • 更新时间: 2018-02-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固