Derafu: Support

GitHub GitHub last commit CI Workflow GitHub code size in bytes GitHub Issues Total Downloads Monthly Downloads

A collection of essential PHP utility classes for the common work of an application: strings, CSV, objects, IP addresses and URL paths.

Every class is final and has only static methods. They keep no state: what a call does depends on its arguments (and on the file system, in the classes that read or write files), so it gives the same answer anywhere and is easy to test.

The classes

Class What it is for Page
Str Placeholders, case conversion, slugs, multibyte padding, UUIDs and random strings. Strings
Encoding UTF-8 and ISO-8859-1, also inside arrays and objects. Strings
Csv Reading, writing, generating and sending CSV. CSV
Obj, Factory, Hydrator Create objects from arrays and look at them. Objects
Serialization, JsonSerializer Is it serializable, and objects to JSON. Objects
Debug Information about a variable and where it was inspected. Objects
Ip IPv4 and IPv6: validation, normalization, ranges and networks. Ip
Url The canonical form of the paths of URLs, and prefixes by segments. Url

For dates, months, periods, working days and date formatting, see Derafu Date. For files, directories, paths, ZIP archives and MIME types, see Derafu File. For typed array reading and array transformations, see Derafu Array. For value inspection, type validation, casting and parsing, see Derafu Value.

Why Derafu\Support?

It solves needs of business and data processing that the standard library leaves out:

  • CSV across systems: separators, enclosures and encodings.
  • Addresses that are handled right: IPv6, ranges and networks, with the same canonical form for the same address.

Install

composer require derafu/support

derafu/array provides the array flattening used by Str::format(). Its exceptions use derafu/translation (see Errors). The following integrations are optional; install the dependencies of the classes you use:

Package Needed by
league/csv (9.27 or later) Csv (all of it).

The string classes (Str, Encoding) use the functions of mbstring.

Errors

The errors that the classes throw are translatable: they are the standard exceptions of PHP (InvalidArgumentException, RuntimeException, LogicException) in the translatable version of derafu/translation, so catching the standard class works, and the message is also available as a message id with its parameters.

The Spanish translations ship with the package. To have them in your translator, import its services (or add SupportTranslationResourceProvider to the resource providers of the translator):

imports:
    - { resource: '../vendor/derafu/support/resources/config/support-services.yaml' }

derafu/foundation already does it.

On this page

Last updated on 15/11/2026 by Anonymous