PHPackages                             seregas/formula - 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. seregas/formula

ActiveLibrary

seregas/formula
===============

Formula

0.3.0(7y ago)344.2k↓18%3[2 PRs](https://github.com/socialist/formula/pulls)GPLPHPPHP ^7.0

Since Oct 30Pushed 1y ago1 watchersCompare

[ Source](https://github.com/socialist/formula)[ Packagist](https://packagist.org/packages/seregas/formula)[ RSS](/packages/seregas-formula/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (4)Versions (3)Used By (0)

formula
=======

[](#formula)

[![Latest Stable Version](https://camo.githubusercontent.com/331049ce1afc569f12d130040fda01d4f1960ae249c56ab4f1c4af6073872724/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736572656761732f666f726d756c612e737667)](https://packagist.org/packages/seregas/formula)[![Build Status](https://camo.githubusercontent.com/4f24e88024495a4b87f6d04d7aa5dc29f61f9591feab87377378abc94415cca2/68747470733a2f2f7472617669732d63692e636f6d2f736f6369616c6973742f666f726d756c612e7376673f6272616e63683d6d6173746572)](https://github.com/socialist/formula)[![Total Downloads](https://camo.githubusercontent.com/8489f4983587800c6e7bdee5c31e4c8ba19deb4aa1f777da79731c85434da449/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736572656761732f666f726d756c612e737667)](https://packagist.org/packages/seregas/formula)

This package can parse and evaluate formulas with variables.

It can take a string with a math expression and parses it so it can be evaluated replacing variables in the expression by given values.

The packages supports operations like addition, subtraction, multiplication and division.

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist seregas/formula "*"

```

or add

```
"seregas/formula": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

Once the extension is installed, simply use it in your code by :

```
$parser = new \socialist\formula\Formula('2 + 3 * 2,65 + 25 - 26');
$parser->calculate(); // 8.95
```

Also in the formula you can use variables:

```
$parser = new \socialist\formula\Formula('2 + 3 * p + 25 - 26');
$parser->setVariable('p', 2,65);
$parser->calculate(); // 8.95
```

And insert comments like `/*...*/`, `[...]` or `{...}`:

```
$parser = new \socialist\formula\Formula('2 + 3 * p /* price */ + 25 - 26');
$parser->setVariable('p', 2,65);
$parser->calculate(); // 8.95
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~815 days

Total

2

Last Release

2671d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cf4d338fefb75a1b7b30661c7d24dc48c549315397dba0b846666923338bfd7d?d=identicon)[socialist](/maintainers/socialist)

---

Top Contributors

[![socialist](https://avatars.githubusercontent.com/u/5237063?v=4)](https://github.com/socialist "socialist (23 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/seregas-formula/health.svg)

```
[![Health](https://phpackages.com/badges/seregas-formula/health.svg)](https://phpackages.com/packages/seregas-formula)
```

PHPackages © 2026

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