Download the PHP package diversified-design/mesuraphp without Composer

On this page you can find all versions of the php package diversified-design/mesuraphp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package mesuraphp

MesuraPHP

A PHP library for representing, converting, and formatting physical measurements — from temperature and pressure to length, weight, and volume — with full SI metric prefix support and a fluent, type-safe API.

Installation

Available Units

Domain Available unit
Angle Degree, Radian
Area Acre, Hectare, SquareFoot, SquareKilometer, SquareMeter, SquareMile + all metric prefixes (see below)
ArealDensity GramPerSquareMeter, KilogramPerSquareMeter, OuncePerSquareYard, PoundPerSquareFoot
Energy BritishThermalUnit, Calorie, FootPound, Joule, Kilocalorie, KilowattHour, WattHour + all metric prefixes (see below)
Irradiance BtuPerHourPerSquareFoot, KilowattPerSquareMeter, WattPerSquareMeter
Length Centimeter, Fathom, Foot, Furlong, HorseLength, Inch, Kilometer, Meter, Millimeter, NauticalMile, StatuteMile, SurveyMile, Thou, Yard + all metric prefixes (see below)
MassConcentration GrainPerCubicFoot, GrainPerCubicMeter, GramPerCubicMeter, KilogramPerCubicMeter, MicrogramPerCubicMeter, MilligramPerCubicMeter
Percentage Percent, PartsPerMillion, PartsPerBillion
Power BtuPerHour, CaloriePerSecond, FootPoundPerSecond, Horsepower, Watt + all metric prefixes (see below)
Pressure Bar, Hectopascal, Kilopascal, Millibar, MillimetreOfMercury, Pascal, PoundPerSquareInch, StandardAtmosphere, Torr
SpecificEnergy BtuPerPound, CaloriePerGram, JoulePerKilogram, KilojoulePerKilogram, MegajoulePerKilogram
Speed KilometerPerHour, Knot, MeterPerSecond, MilesPerHour
Temperature Celsius, Fahrenheit, Kelvin, Rankine
Time Day, Hour, Minute, Second
Torque NewtonMeter
Volume CubicInch, CubicMeter, CubicYard, FluidDram, FluidOunce, ImperialFluidDram, ImperialFluidOunce, ImperialPint, ImperialQuart, Liter, Pint, Quart, TableSpoon + all metric prefixes (see below)
Weight Gram, Kilogram, MetricTon, Pound + all metric prefixes (see below)

All the units of a domain can be converted to each other with corresponding methods.

Full SI Metric Prefix Support

Length, Weight, Volume (liters), Area (square meters), Energy (joules), and Power (watts) support all 24 SI metric prefixes — from Quetta (10^30) down to Quecto (10^-30). For example, Length includes Quettameter, Megameter, Kilometer, Centimeter, Nanometer, Quectometer, and everything in between. The same applies to the other metric dimensions (e.g. Milligram, Kiloliter, SquareCentimeter, Megajoule, Gigawatt).

Common prefixed units have dedicated convenience methods (e.g. ->toNanometer(), ->toMilligram()). All others are accessible via ->toUnit(Yottameter::class).

Unit System Classification

Every unit exposes its measurement system via unitSystem():

Available systems: SI, Metric, Imperial, USCustomary, Nautical, Dimensionless, Other.

See ./examples/unit_system.php for filtering and grouping examples.


Basic Usage

Set the value of the measurement unit directly

Convert to another unit in the same domain:

See many more examples in ./examples/fluent_conversions.php & ./examples/complete_example.php

Fluent Usage

The same example as above, but fluently

See more examples in ./examples/fluent_conversions.php

Formatting output

Formatting methods use sprintf()

See the examples in ./examples/formatting.php

Setting Custom Symbols

All units have default symbols already assigned, but you can set custom ones per instance or per lifecycle.

See the examples in ./examples/symbol_manipulation.php

You can also customize all units up-front in one go using the Customize class' ::unitSymbols() static method.

See the examples in ./examples/customize_units.php


Credit Due

This codebase is a much expanded and heavily modified "hard" fork of the excellent PrinsFrank/measurement-unit.

It adds several utility methods, many more units across more domains, and relies on Brick\Math for all conversions.


LLMs, Coding Agents, etc…

Yes, this work relies heavily on such tools. It is however not "vibe coded" nor "one-shotted."

As an artisan, I use the tools available as tools: to help me make better things, and learn faster.

Did I write every line of code? No. Do I understand every single part of it. No, but most of it.

I did (re)architect and (re)design it with my own knowledge, experience and needs, discussing with and instructing agents as I would have with a team of engineers.

Issues and Pull Requests from fellow humans are always welcome.


I hope you find this library as useful and pleasurable to use as I do.


All versions of mesuraphp with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
brick/math Version ^0.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package diversified-design/mesuraphp contains the following files

Loading the files please wait ...