PHPackages                             josefelipetto/math-expression-parser - 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. josefelipetto/math-expression-parser

ActiveLibrary

josefelipetto/math-expression-parser
====================================

A component to parse all kind of numerical expressions and solve them

1162PHPCI failing

Since Apr 9Pushed 6y ago1 watchersCompare

[ Source](https://github.com/josefelipetto/math-expression-parser)[ Packagist](https://packagist.org/packages/josefelipetto/math-expression-parser)[ RSS](/packages/josefelipetto-math-expression-parser/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

math-expression-parser
======================

[](#math-expression-parser)

A Math expression parser built in PHP.

Requirements
============

[](#requirements)

- PHP 7.1

Installation
============

[](#installation)

You can install the component by using composer.

`composer require josefelipetto/math-expression-parser`

How to use
==========

[](#how-to-use)

You can use in two ways:

- Using the ExpressionParser facade that already mount the dependecies of the Evaluator class and returns the result, like this:

```
use Parser\Facades\ExpressionParser;

$result = ExpressionParser::parse('(2+2)^(2*2)/1+3+5');

assert($result === 264);
```

- Or you can actually use you own implementation of a Lexer and/or AST by providing the dependencies to the classes, like this:

```
use Parser\Evaluator;
use Parser\Lexer; // Or your Lexer
use Parser\Syntactic; // Or your AST

$evaluator = new Evaluator(new Syntactic(new Lexer('(2+2)^(2*2)/1+3+5')));

assert($evaluator->parse() === 264);
```

Grammar
=======

[](#grammar)

The parser accepts the following operators: + ; - ; . ; \* ; / ; ^ ; ( ; )

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/17f8d64a772891d82ebf1d25726c414dba8332021f034c0ac0e4f5cd89ef2eeb?d=identicon)[josefelipetto](/maintainers/josefelipetto)

---

Top Contributors

[![josefelipetto](https://avatars.githubusercontent.com/u/2763539?v=4)](https://github.com/josefelipetto "josefelipetto (31 commits)")

### Embed Badge

![Health badge](/badges/josefelipetto-math-expression-parser/health.svg)

```
[![Health](https://phpackages.com/badges/josefelipetto-math-expression-parser/health.svg)](https://phpackages.com/packages/josefelipetto-math-expression-parser)
```

PHPackages © 2026

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