mistralys / application-utils
Drop-in utilities for PHP applications.
Installs: 71 968
Dependents: 15
Suggesters: 0
Security: 0
Stars: 6
Watchers: 5
Forks: 1
Open Issues: 2
Requires
- php: >=7.4
- ext-curl: *
- ext-dom: *
- ext-gd: *
- ext-json: *
- ext-libxml: *
- ext-mbstring: *
- ext-simplexml: *
- ext-zip: *
- mistralys/application-utils-core: >=2.2.3
- mistralys/application-utils-image: >=1.1
- parsecsv/php-parsecsv: >=1.3
Requires (Dev)
- phpstan/phpstan: >=1.10
- phpunit/phpunit: >=9.6
Suggests
- mistralys/application-localization: Required to translate available texts, from date related methods or file size labels for example.
- dev-main
- 3.1.0
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 3.0.0-alpha2
- 3.0.0-alpha1
- 2.5.0
- 2.4.1
- 2.4.0
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.11
- 2.2.10
- 2.2.9
- 2.2.8
- 2.2.7
- 2.2.6
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.1
- 2.0.0
- 1.9.1
- 1.9.0
- 1.8.1
- 1.8.0
- 1.7.1
- 1.7.0
- 1.6.0
- 1.5.1
- 1.5.0
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.1
- 1.3.0
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-move-image-helper
This package is auto-updated.
Last update: 2024-12-14 10:21:51 UTC
README
Application Utilities
Drop-in static PHP utility classes for common tasks, from file system related operations and variable conversions to image manipulation.
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.