mistralys/application-utils 问题修复 & 功能扩展

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

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

mistralys/application-utils

Composer 安装命令:

composer require mistralys/application-utils

包简介

Drop-in utilities for PHP applications.

README 文档

README

Drop-in static PHP utility classes for common tasks, from file system related operations and variable conversions to image manipulation.

Composition

This package is an aggregation of several separate libraries upon which the application utilities are built. Depending on the features you need, you may not need to install this package in its entirety.

The following libraries are included in this package:

Requirements

  • PHP v7.4+
  • Extensions:
    • MBString
    • CURL
    • Json
    • GD
    • Zip
    • Dom
    • SimpleXML

Installation

Simply require the package with Composer:

composer require mistralys/application-utils

Also see the Packagist page.

Translation support

To enable localization of any translatable strings in the package, require the Application Localization package as well. German and French translations are included, and the integrated interface allows adding additional translations.

Other translation solutions are not supported.

composer require mistralys/application-localization

Note: The StringBuilder helper's translation methods depend on the package being installed.

Quickstart

The package is meant to simplify day to day development tasks, from common file system related access to converting data types. It uses exception-based error handling, so there is no need for checking PHP function return values for false.

There is no central factory for accessing the helpers. Instead, each static helper class has its own factory methods and acts as hub for all related tasks.

For example, all file related tasks live in the FileHelper class.

use AppUtils\FileHelper;

// Replacement for file_get_contents
$content = FileHelper::readContents('path/to/file');

Likewise, conversion methods live in the ConvertHelper class.

use AppUtils\ConvertHelper;

$bool = ConvertHelper::string2bool('yes');

The helpers overview below can give you an idea of what is available.

Overview of helpers

This overview is an excerpt of the available utility classes in the package. It shows only the main functionality - classes like the ConvertHelper for example have many static methods not shown here.

  • BaseException: Exception class with extended functionality.
  • BoolValue: Object oriented boolean values with one-way "sticky" values.
  • ConvertHelper: Converting dates, strings, transliterating and more.
    • ByteConverter: Convert byte values to kilobytes, megabytes...
    • ControlCharacters: Detecting and stripping control characters from strings.
    • DateInterval: Wrapper around the native DateInterval to fix common pitfalls.
    • DurationConverter: Convert time durations to human-readable formats.
    • EOL: Detect the newline style used in a string or file.
    • HiddenConverter: Converts hidden characters to readable for debugging.
    • IntervalConverter: Convert date intervals to human-readable formats.
    • QueryParser: Parse query formatted strings without the native limitations.
    • SizeNotation: Convert size strings (2 MB) to byte values.
    • TabsNormalizer: Allows intelligently left-adjusting indented text.
    • ThrowableInfo: Exception analysis tool for debugging, and persisting them to storage.
    • URLFinder: Allows detecting URLs in a string.
    • WordWrapper: Intelligently wrap text to a specific length.
  • ClassHelper: Static analysis-friendly class loading methods and Composer ClassLoader access.
  • CSVHelper: Read and generate CSV files.
  • Highlighter: Syntax highlighting using GeSHi, as well as some custom variants.
  • JSHelper: generate JavaScript statements from PHP with automatic PHP > JS conversion of variables.
  • FileHelper: File system utility methods and file finder.
    • FileFinder: Fetching file lists by filters, recursive or not.
    • PHPClassInfo: Fetch basic class info from PHP files without reflection.
    • MimeTypes: List of commonly used mime types.
    • PathsReducer: Reduce a list of absolute paths to a common root.
  • HTMLHelper: Common HTML utility methods.
    • HTMLTag: Object-Oriented HTML tag generation.
    • AttributeCollection: Collection class for attributes (HTML or other).
  • ImageHelper: Image manipulation using native GD functions with alpha support.
    • RGBAColor: Color container class with alpha channel support.
  • IniHelper: INI file reader and editor.
  • Microtime: DateTime class with microseconds support and friendly methods interface.
  • NamedClosure: Wrapper for closures with the possibility to add a description.
  • NumberInfo: Access and modify numbers with or without units.
  • OperationResult: Drop-in class to store the status of the result of any operation.
  • OutputBuffering: Output buffering wrapper with exception error management.
  • PaginationHelper: Calculates all required numbers for a pagination widget.
  • RegexHelper: Collection of typical validation Regexes.
  • Request: Validate, filter and access request variables.
    • URLComparer: Compare URLs, including query parameters.
    • RequestHelper: Build raw requests from scratch with multipart support.
    • AcceptHeaders: Allows parsing the Accept: header.
  • StringBuilder: Easily concatenate strings, with formatting helpers, in a chainable interface.
  • SVNHelper: working with a local SVN repository. Update, commit, etc.
  • Traits and Interfaces: Plug-in traits for common tasks, with matching interfaces.
    • Classable: For elements that can have classes, like HTML elements.
    • Optionable: For elements which allow setting options, with strong typing.
    • Stringable: For elements with the __toString() method.
  • Transliteration: Simple transliteration to ASCII for any names.
  • URLInfo: An object-oriented parse_url with fixes for a number of pitfalls.
    • Highlighter: Highlights URLs with integrated CSS.
    • Normalizer: Normalizes a URL, including query parameter sorting.
  • VariableInfo: Information on any PHP variable types with string conversion.
  • XMLHelper: Simplifies working with some XML libraries like DOM or SimpleXML.
    • HTMLLoader: Easy loading of HTML fragments or whole documents.
    • DOMErrors: LibXML parsing errors made easy with OO interface.
    • LibXML: Constants for all LibXML validation errors.
    • SimpleXML: Wrapper for SimpleXML with a number of utility methods.
    • Converter: Convert XML/HTML to arrays and json.
  • ZIPHelper: Abstracts working with the ZIPArchive class.

Documentation

Documentation for the helper classes is ongoing in the Application Utils Wiki.

Origin

These classes are still in use in a number of legacy applications. They were originally scattered over all of these applications, with their code diverging over time. This repository aims to consolidate them all into a single package to make it easier to maintain them.

As the legacy applications are still being maintained, this package is actively maintained and being modernized.

mistralys/application-utils 适用场景与选型建议

mistralys/application-utils 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 139.51k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2019 年 10 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 mistralys/application-utils 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mistralys/application-utils 我们能提供哪些服务?
定制开发 / 二次开发

基于 mistralys/application-utils 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 139.51k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 17
  • 依赖项目数: 14
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-08