PHPackages                             mathematicator-core/calculator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mathematicator-core/calculator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mathematicator-core/calculator
==============================

Advance PHP math calculator with complex operations.

v3.0.2(5y ago)23.0k2[2 PRs](https://github.com/mathematicator-core/calculator/pulls)2MITPHPPHP ^8.0

Since Jul 25Pushed 3y ago1 watchersCompare

[ Source](https://github.com/mathematicator-core/calculator)[ Packagist](https://packagist.org/packages/mathematicator-core/calculator)[ Docs](https://github.com/mathematicator-core/calculator)[ RSS](/packages/mathematicator-core-calculator/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (19)Versions (23)Used By (2)

 Advance PHP Calculator
========================

[](#----advance-php-calculator)

 [ ![](https://avatars3.githubusercontent.com/u/44620375?s=100&v=4) ](https://mathematicator.com)

[![Integrity check](https://github.com/mathematicator-core/calculator/workflows/Integrity%20check/badge.svg)](https://github.com/mathematicator-core/calculator/actions?query=workflow%3A%22Integrity+check%22)[![codecov](https://camo.githubusercontent.com/fc19323337d70bff606d5915194d7d3c287cfd5cd66e971283b185a33def11c1/68747470733a2f2f636f6465636f762e696f2f67682f6d617468656d6174696361746f722d636f72652f63616c63756c61746f722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/mathematicator-core/calculator)[![Latest Stable Version](https://camo.githubusercontent.com/17984128e20acbed449cfae9f96522be96b85f2e66861b4f907f55abd6a2f564/68747470733a2f2f706f7365722e707567782e6f72672f6d617468656d6174696361746f722d636f72652f63616c63756c61746f722f762f737461626c65)](https://packagist.org/packages/mathematicator-core/calculator)[![Latest Unstable Version](https://camo.githubusercontent.com/2ded891e32f35d368acb8a54bda519f12833cbc82918e379144c23ac9af602f6/68747470733a2f2f706f7365722e707567782e6f72672f6d617468656d6174696361746f722d636f72652f63616c63756c61746f722f762f756e737461626c65)](https://packagist.org/packages/mathematicator-core/calculator)[![License: MIT](https://camo.githubusercontent.com/1a2e0606685ce00663bf829868f794fd3fc9c86f8d80cae324734129e0723a58/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d627269676874677265656e2e737667)](./LICENSE)[![PHPStan Enabled](https://camo.githubusercontent.com/9142f3d2ec7588a75127608ff41f595540402524559c6f50feb756df4b8cf6c5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642532304c382d627269676874677265656e2e7376673f7374796c653d666c6174)](https://phpstan.org/)

Simple to use **modular calculator** with **steps to solution** and **result explanation**.

It is highly recommended to make sure you have enabled [BCMath](https://www.php.net/manual/en/book.bc.php)or [GMP](https://www.php.net/manual/en/book.gmp.php) extension on your PHP server for much faster calculations.

Installation
------------

[](#installation)

```
composer require mathematicator-core/calculator

```

Idea
----

[](#idea)

Imagine you want compute some math problem, for instance:

```
(5 + 3) * (2 / (7 + 3))

```

How to compute it? Very simply:

```
$calculator = new Calculator(/* some dependencies */);

echo $calculator->calculateString('(5 + 3) * (2 / (7 + 3))'); // \frac{8}{5}
```

Method `calculateString()` returns entity `CalculatorResult` that implements `__toString()` method.

Advance use is by an array of tokens created by `Tokenizer`:

```
$tokenizer = new Tokenizer(/* some dependencies */);

// Convert math formule to array of tokens:
$tokens = $tokenizer->tokenize('(5+3)*(2/(7+3))');

// Now you can convert tokens to more useful format:
$objectTokens = $tokenizer->tokensToObject($tokens);

$calculator->calculate($objectTokens);
```

Mathematicator Framework tools structure
----------------------------------------

[](#mathematicator-framework-tools-structure)

The biggest advantage is that you can choose which layer best fits your needs and start build on the top of it, immediately, without the need to create everything by yourself. Our tools are tested for bugs and tuned for performance, so you can save a significant amount of your time, money, and effort.

Framework tend to be modular as much as possible, so you should be able to create an extension on each layer and its sublayers.

**Mathematicator framework layers** ordered from the most concrete one to the most abstract one:

    **[ Search ](https://github.com/mathematicator-core/search)**    Modular search engine layer that calls its sublayers and creates user interface.      **[ Vizualizator ](https://github.com/mathematicator-core/vizualizator)**    Elegant graphic visualizer that can render to SVG, PNG, JPG and Base64.
 Extensions:  **[ Mandelbrot set generator ](https://github.com/mathematicator-core/mandelbrot-set)**       **[ Calculator ](https://github.com/mathematicator-core/calculator)**    Modular advance calculations layer.
 Extensions:  **[ Integral Solver ](https://github.com/mathematicator-core/integral-solver), [ Statistics ](https://github.com/mathematicator-core/statistic)**       **[ Engine ](https://github.com/mathematicator-core/engine)**    Core logic layer that maintains basic controllers, DAOs, translator, common exceptions, routing etc.      **[ Tokenizer ](https://github.com/mathematicator-core/tokenizer)**    Tokenizer that can convert string (user input / LaTeX) to numbers and operators.      **[ Numbers ](https://github.com/mathematicator-core/numbers)**    Fast &amp; secure storage for numbers with arbitrary precision. It supports Human string and LaTeX output and basic conversions.  **Third-party packages:**

⚠️ Not guaranteed!

    **[ REST API ](https://github.com/cothema/math-php-api)**    Install the whole pack as a REST API service on your server (Docker ready) or access it via public cloud REST API.  Contribution
------------

[](#contribution)

> Please help improve this documentation by sending a Pull request.

### Tests

[](#tests)

All new contributions should have its unit tests in `/tests` directory.

Before you send a PR, please, check all tests pass.

This package uses [Nette Tester](https://tester.nette.org/). You can run tests via command:

```
composer test
```

Before PR, please run complete code check via command:

```
composer cs:install # only first time
composer fix # otherwise pre-commit hook can fail
```

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 68% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~32 days

Total

19

Last Release

1946d ago

Major Versions

v1.0.8 → v2.0.02020-04-14

v2.0.6 → v3.0.02021-02-10

PHP version history (3 changes)v1.0.0PHP &gt;=7.1

v2.0.5PHP &gt;=7.2

v3.0.0PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3382204?v=4)[baraja](/maintainers/baraja)[@baraja](https://github.com/baraja)

---

Top Contributors

[![janbarasek](https://avatars.githubusercontent.com/u/4738758?v=4)](https://github.com/janbarasek "janbarasek (66 commits)")[![flokixdev](https://avatars.githubusercontent.com/u/2387790?v=4)](https://github.com/flokixdev "flokixdev (26 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (5 commits)")

---

Tags

arithmeticcalculatorcomputingequationmathnumber-theoryphpmathmathematicator

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mathematicator-core-calculator/health.svg)

```
[![Health](https://phpackages.com/badges/mathematicator-core-calculator/health.svg)](https://phpackages.com/packages/mathematicator-core-calculator)
```

###  Alternatives

[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.3k10](/packages/helsingborg-stad-municipio)[mathematicator-core/tokenizer

Math Tokenizer

104.9k6](/packages/mathematicator-core-tokenizer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
