Search by

raxos / foundation

basmilius

Base stuff for all Raxos libraries.

3.2.0 2026-10-02 17:09 UTC

README

Bas Milius

Raxos Foundation

Shared value objects, access traits and utility functions used throughout Raxos.

Documentation | Packagist | Raxos

  • Option, Some and None for optional values.
  • IP parsing and array/magic-property access traits.
  • Array, string, color, filesystem, math, reflection and XML utilities.
  • Singleton instances, stopwatches and preloading helpers.

Installation

Requires PHP 8.5 or later. Enable the dom, intl, json, mbstring, openssl, simplexml PHP extensions. Composer checks the remaining package and extension dependencies declared in composer.json.

composer require "raxos/foundation:^3.2"

Usage

<?php
declare(strict_types=1);

use Raxos\Foundation\Network\IP;
use Raxos\Foundation\Option\Option;

require __DIR__ . '/vendor/autoload.php';

$ip = IP::parse('203.0.113.10');
$label = Option::fromValue($ip?->value)
    ->map(static fn(string $value): string => "Client {$value}")
    ->getOrElse('Unknown client');

echo $label;

Option::fromValue() treats null as absent by default; values such as 0, false and an empty string remain present. Pass a different sentinel as the second argument when needed.

Documentation

Testing

Run this library's Pest suite from the Raxos workspace:

git clone --recurse-submodules https://github.com/basmilius/raxos.git
cd raxos
composer install
vendor/bin/pest --testsuite=foundation

See Testing Raxos for PHP extensions, integration services and coverage commands. The library's Tests workflow also runs in GitHub Actions.

License

MIT. Copyright (c) 2017 - present Bas Milius.