Private extension

Keep the unit attached.
mathphp-units

A private extension for dimensional quantities, conversions, and readable expressions such as 2m * 6 + 200cm or 25m to km.

mathphp-units

Designed to load separately.

Keep mathphp/mathphp small and stable. This package adds its own contracts, translations, and presentation models without changing the public evaluator.

  • Length, area, volume, mass, time, temperature, and angle units
  • Litres, square/cubic lengths, and explicit speed units
  • Automatic conversion before compatible addition
  • Dimensional algebra with stable errors
Read integration notes ↗
Normalize or convert25m to km
  1. 1Read the source quantity25 m is stored as 25 base metres25 m
  2. 2Convert the display unit1 km = 1000 m · 25 ÷ 10000.025 km
Converted quantity0.025 km
// normalize compatible quantities
$total = UnitMath::evaluate('2m * 6 + 200cm');
// 14 m
$distance = UnitMath::evaluate('25m to km');
// 0.025 km

Install from an approved source

These repositories are private and may be consumed through your organization’s Composer mirror or VCS access. Pin a tag or commit for production.

# add the approved private VCS source
composer config repositories.mathphp-units vcs https://github.com/mathphp/mathphp-units.git
composer require mathphp/mathphp-units:^0.1
Distribution placeholder.Private repositories and commercial terms are intentionally not automated yet; the delivery model will be chosen separately.
What it adds
01

Dimensions stay honest

Length, mass, time, temperature, and angle are represented explicitly so adding metres to seconds fails clearly.

02

Convert on demand

Use the explicit to operator, such as 25m to km, to choose a compatible display unit without losing the normalized value.

03

Composable output

Serialize value, unit, dimensions, and a formatted label for the playground, APIs, or the explaining add-on.

How it fits

One core call.
One richer response.

01EvaluateCore parses and validates the expression.
02EnrichUnits normalizes dimensions and conversions.
03PresentYour application chooses the UI, language, and renderer.
Feature guides