chriskonnertz/string-calc
StringCalc is a lightweight PHP library that evaluates mathematical expressions passed as strings, turning terms like 1+1 or sqrt(16)*2 into results. It supports basic operators, brackets, and common functions, with no dependencies—ideal for calculators and formula inputs.
Architecture fit
eval(). That matters in a Laravel codebase where the alternative is usually a hand-rolled eval() shim buried in a service class.ExpressionEvaluator) rather than being called directly from controllers or models.Integration feasibility
composer require chriskonnertz/string-calc and a container binding; no service provider, no config publishing, no migrations. Effort is measured in hours, not sprints.Technical risk
Key questions
+ - * / ( ) — min/max, rounding, percentages, variables, unit handling? The library's grammar coverage must be confirmed against the actual formula spec before commitment.Stack fit
Migration path
ExpressionEvaluator (interface) with a StringCalc implementation and a fake for tests. This makes the package replaceable in one file if it is abandoned or outgrown.eval()-based calculator exists, migrate by running both implementations in parallel (dual-write/compare) on production terms, diffing results before cutover. Any result divergence is a spec question, not a bug report.Compatibility
composer.json and lock it. Do not allow float within a major if the package ever resumes releasing.. as decimal separator at the input boundary and normalize before evaluation.Sequencing
Maintenance
Support
Scaling
term → result keyed by normalized expression.Failure modes
INF/NAN into persistence.Ramp-up
How can I help you explore Laravel packages today?