Mistralys / application-utils

Drop-in static PHP utility classes
GNU General Public License v3.0
6 stars 1 forks source link
conversion file-system helpers-library library php utilities-library

Build Status Scrutinizer Code Quality

Application Utilities

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

Requirements

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.

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.