Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Math Parser Laravel Package

mossadal/math-parser

Safe PHP math expression parser/evaluator that builds an AST from user formulas. Supports arithmetic, variables, and elementary functions, plus interpreters for evaluation, symbolic differentiation, and LaTeX pretty-printing; customizable lexer/parser with StdMathParser.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Dynamic Formula Evaluation: Enable user-submitted or configurable mathematical expressions in products like pricing calculators, scientific tools, or financial modeling platforms without building custom parsing logic.
  • Symbolic Math Capabilities: Integrate symbolic differentiation for applications requiring optimization algorithms, physics simulations, or AI/ML training data generation.
  • Rich Mathematical Notation: Support LaTeX rendering for educational platforms, documentation, or interactive dashboards (via MathJax or similar libraries).
  • Build vs. Buy Decision: Avoid reinventing a robust math parser, reducing development time and technical debt while leveraging a well-tested, open-source solution.
  • Roadmap Prioritization: Fast-track features requiring math parsing (e.g., "add custom formula support" in a SaaS product) by leveraging pre-built AST and interpreters.
  • Security and Compliance: Replace unsafe eval() usage with a controlled, AST-based evaluation system, reducing security risks associated with user-submitted code.
  • Cross-Functional Use Cases: Enable collaboration between engineering, product, and design teams by providing a standardized way to handle mathematical expressions across the stack.

When to Consider This Package

  • Adopt if:

    • Your application requires evaluating or manipulating user-provided math expressions (e.g., calculators, rule engines, or dynamic pricing).
    • You need symbolic differentiation for algorithmic or educational use cases (e.g., optimization, physics simulations).
    • You want to avoid security risks of eval() while parsing untrusted input.
    • Your team lacks expertise in building a math parser from scratch, or you want to reduce development time.
    • You need LaTeX output for rich mathematical notation in documentation, educational platforms, or interactive dashboards.
    • Your use case aligns with the package’s supported features (e.g., elementary functions, variables, implicit multiplication).
  • Look elsewhere if:

    • You require advanced numerical computing (e.g., matrix operations, statistics) → consider alternatives like Symfony Math or PHP-ML.
    • Your expressions are extremely complex (e.g., full computer algebra system support) → evaluate commercial libraries or frameworks like Symja.
    • You’re constrained by the LGPL-3.0 license and cannot comply with its terms (e.g., open-sourcing modifications).
    • Performance is critical for high-frequency evaluations, and benchmarks show this package is insufficient (e.g., for real-time trading systems).
    • You need GPU acceleration or parallel processing for large-scale computations.

How to Pitch It (Stakeholders)

For Executives: "This package allows us to embed dynamic mathematical formulas into our product—such as custom pricing rules, scientific simulations, or rule-based workflows—without building a parser from scratch. It’s secure (no eval), supports advanced features like symbolic differentiation for algorithmic use cases, and even generates LaTeX for better user experience in documentation or dashboards. By adopting this solution, we can accelerate feature development, reduce technical debt, and enhance our product’s capabilities in math-heavy domains with minimal risk."

For Engineers: "The mossadal/math-parser package provides a robust, PHP-based solution for parsing and evaluating mathematical expressions, including support for variables, elementary functions, implicit multiplication, and symbolic differentiation. It integrates seamlessly with Laravel via Composer and offers three interpreters: an evaluator for numeric results, a differentiator for symbolic math, and a LaTeX generator for rich output. The package is lightweight, well-documented, and avoids the security pitfalls of eval(). While it may not handle the most complex numerical computing tasks, it’s a solid choice for dynamic formula evaluation, optimization algorithms, or educational tools. The LGPL-3.0 license is permissive for most use cases, though we should ensure compliance if we modify the code."

For Product Managers: "This package enables us to deliver features like customizable calculators, dynamic pricing models, or scientific simulations without heavy engineering lift. For example, we could add a ‘custom formula’ field to our pricing tool, allowing users to define their own cost structures using mathematical expressions. The symbolic differentiation feature could also unlock advanced use cases like optimization algorithms or AI training data generation. By leveraging this solution, we can iterate faster on math-related features while maintaining security and scalability."

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky