Download the PHP package php-rpn/rpn without Composer

On this page you can find all versions of the php package php-rpn/rpn. 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 rpn

RPN - Reverse Polish Notation Calculator

A flexible and extensible PHP library for parsing and evaluating mathematical expressions using Reverse Polish Notation (RPN). It uses a Shunting-yard algorithm implementation that is configurable and easy to use.

What is Reverse Polish Notation?

Reverse Polish Notation (also called postfix notation) is a mathematical notation in which operators follow their operands. For example:

RPN eliminates the need for parentheses and operator precedence rules during evaluation, making it simpler and faster to compute.

Installation

Requirements

Features

Usage

The library is designed with a fluent builder to make parsing and evaluation straightforward.

Basic Usage

Using Mathematical Functions

Using Variables

Customization

You can easily add your own custom operators if you need to. Just implement the OperatorInterface and register it with the parser builder:

Supported Syntax

The default parser supports both standard ASCII and Unicode mathematical symbols:

Operation ASCII Unicode Example
Addition + - 1 + 7
Subtraction - - 5 - 49
Multiply * × 3 × 4
Divide / ÷ 10 ÷ 2
Power ^, pow - 2 ^ 3
Factorial ! - 5!
Square Root sqrt √ sqrt(16) or √16
Cube Root - ∛ ∛27
Fourth Root - ∜ ∜81
Exponential function exp - exp(3)
Min min - min(3, :x)
Max min - max(7, :x)
Log log - log(10)
Percent % - 5%
Negation - - -3

Development

Feel free to contribute! Fork the repository and submit a pull request. Just make sure everything satisfies the coding standards and all tests pass.

How It Works

1. Parsing (Infix to RPN)

The ShuntingYardParser converts an infix string like 3 + 4 * 2 into an ExpressionPartsStream.

Token Action Output Stream (Conceptual) Operator Stack
3 Add to stream [Number(3)]
+ Push to stack [Number(3)] [+]
4 Add to stream [Number(3), Number(4)] [+]
* Higher precedence, push [Number(3), Number(4)] [+, *]
2 Add to stream [Number(3), Number(4), Number(2)] [+, *]
End Pop all operators [Number(3), Number(4), Number(2), *, +]

2. Evaluation

The Expression::evaluate() method iterates the ExpressionPartsStream and uses a stack to compute the result.

Expression Stream: [Number(3), Number(4), Number(2), *, +]

Token Stack After Explanation
3 [3] Push 3
4 [3, 4] Push 4
2 [3, 4, 2] Push 2
* [3, 8] Pop 4, 2; compute 4*2=8; push 8
+ [11] Pop 3, 8; compute 3+8=11; push 11

License

This library is licensed under the MIT License - see the LICENSE file for details.

Author

Olexandr Mazur [email protected]

:star: Star this project on GitHub — it motivates me a lot!


All versions of rpn with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
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 php-rpn/rpn contains the following files

Loading the files please wait ...