Download the PHP package j84reginato/my-eval without Composer

On this page you can find all versions of the php package j84reginato/my-eval. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package my-eval

My-eval

Latest Stable Version Total Downloads License Code Climate

DESCRIPTION

PHP parser and evaluator library for mathematical and logical expressions.

Intended use: safe and reasonably efficient evaluation of user submitted formulas and/or logical expressions. The library supports basic arithmetic and elementary functions, as well as variables and extra functions, ternary ( if/then/else) expressions and conditional, logical (conjunction and disjunction) and relational operations.

The lexer and parser produces an abstract syntax tree (AST) that can be traversed using a tree interpreter. The math-parser library ships with three interpreters:

EXAMPLES

It is possible to fine-tune the lexer and parser, but the library ships with a StdMathParser class, capable of tokenizing and parsing standard mathematical expressions, including arithmetical operations as well as elementary functions.

~~~{.php} Use MyEval\Lexing\StdMathLexer; use MyEval\Parsing\Parser; use MyEval\Solving\StdMathEvaluator;

// Tokenize $lexer = new StdMathLexer(); $tokens = $lexer->tokenize('1+2');

// Parse // Generate an abstract syntax tree $parser = new Parser(); $ast = $parser->parse($tokens);

// Do something with the AST, e.g. evaluate the expression: $evaluator = new StdMathEvaluator(); $value = $ast->accept($evaluator); echo $value;


More interesting example, containing variables:

~~~{.php}
Use MyEval\Lexing\StdMathLexer;
use MyEval\Parsing\Parser;
use MyEval\Solving\StdMathEvaluator;

// Tokenize
$lexer = new StdMathLexer();
$tokens = $lexer->tokenize('x+sqrt(y)');

// Parse
// Generate an abstract syntax tree
$parser = new Parser();
$ast = $parser->parse($tokens);

// Evaluate
$evaluator = new StdMathEvaluator([ 'x' => 2, 'y' => 3 ]);
$value = $ast->accept($evaluator);

We can do other things with the AST. The library ships with a differentiator, computing the (symbolic) derivative with respect to a given variable.

~~~{.php} use MyEval\Lexing\StdMathLexer; use MyEval\Parsing\Parser; use MyEval\Solving\Differentiator; use MyEval\Solving\StdMathEvaluator;

// Tokenize $lexer = new StdMathLexer(); $tokens = $lexer->tokenize('exp(2x)-xy');

// Parse // Generate an abstract syntax tree $parser = new Parser(); $ast = $parser->parse($tokens);

// Differentiate $differentiator = new Differentiator('x'); $derivative = $ast->accept($differentiator); $df = $derivative->accept($differentiator);

// Evaluate // $df now contains the AST of '2*exp(x)-y' and can be evaluated further $evaluator = new StdMathEvaluator([ 'x' => 1, 'y' => 2 ]); $value = $df->accept($evaluator);



### Implicit multiplication

Another helpful feature is that the parser understands implicit multiplication. An expression as `2x` is parsed the same
as `2*x` and `xsin(x)cos(x)^2` is parsed as `x*sin(x)*cos(x)^2`.

Note that implicit multiplication has the same precedence as explicit multiplication. In particular, `xy^2z` is parsed
as `x*y^2*z` and **not** as `x*y^(2*z)`.

To make full use of implicit multiplication, the standard lexer only allows one-letter variables. (Otherwise, we
wouldn't know if `xy` should be parsed as `x*y` or as the single variable `xy`).

## DOCUMENTATION

For complete documentation, see the [TODO]()

## THANKS

The Lexer is based on the lexer described by Marc-Oliver Fiset in
his [blog](http://marcofiset.com/programming-language-implementation-part-1-lexer/).

The parser is a version of the "Shunting yard" algorithm, described for example
by [Theodore Norvell](http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm#shunting_yard).

All versions of my-eval with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
phplucidframe/console-table Version ^1.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package j84reginato/my-eval contains the following files

Loading the files please wait ....