Foundation
Raxos Foundation is the small, dependency free package that underpins every other Raxos library. It has no dependencies on other Raxos packages and provides the primitives that keep the rest of the ecosystem consistent: magic property and array access traits, a functional Option type for representing optional values, an IP value object, a Singleton registry, and a set of static Util classes for arrays, colors, math, strings, XML, reflection, timing and debug output. A handful of global functions round out the package.
Highlights
OptionA functional optional value type with Some and None, no more juggling null.IPValidate and parse IPv4 and IPv6 addresses into a small value object.SingletonA tiny registry that keeps one shared instance per class name.StopwatchMeasure elapsed time with a high resolution timer and report it in any unit.ArrayUtilFlatten, group, filter and slice plain arrays and iterables.StringUtilSlugify, case convert, truncate and format strings.Explore by category
- Access traits: expose array syntax and magic property access from a single set of accessor methods.
- Option type: represent an optional value with
SomeandNoneinstead of relying onnull. - Network: IP: validate and parse IPv4 and IPv6 addresses.
- Util classes: static helpers for arrays, colors, math, strings, XML, reflection and debugging.
- Singleton, Stopwatch and global functions: shared instances, timing and process helpers.
Quick example
php
<?php
declare(strict_types=1);
use Raxos\Foundation\Network\IP;
use Raxos\Foundation\Option\Option;
$ip = IP::parse('203.0.113.10');
$name = Option::fromValue($ip?->value)
->map(static fn(string $value): string => "client@{$value}")
->getOrElse('client@unknown');Installation
Install the package with Composer. See installation for the required PHP version and extensions.
shell
composer require raxos/foundation