Download the PHP package okvpn/expression-language without Composer
On this page you can find all versions of the php package okvpn/expression-language. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download okvpn/expression-language
More information about okvpn/expression-language
Files in okvpn/expression-language
Package expression-language
Short Description Fast powerful PHP expression language based on twig syntax
License MIT
Homepage https://github.com/okvpn/expression-language
Informations about the package expression-language
PHP Expression Language based on TWIG
This library provides interfaces for safe evaluate expressions, compile them to native PHP code for performance.
Purpose
It is an alternative to the Symfony Expression Language which allows more operations such as for
if
etc.
You can to implement any logic and execute it safely and quickly. We removed PRINT_TOKEN
TEXT_TOKEN
from
TWIG AST-tree to prevent output, added return
statement and made a more improvement.
Features
- Allow to execution scripts and evaluate expressions.
- Debugging with PhpStorm twig debugger feature.
- Support all twig features, like sandbox, custom extension, tokens, functions.
- Minimum performance overhead - faster that twig.
- Syntax highlighting is already built into the most popular IDEs.
Example Usage
Base evaluate Example
Execute Script
evaluate
method - is faster than execute
, because we skip additional exception handling and error logic.
Also evaluate
- accept code without {%
token.
Benchmark Test
We use next the test to compare overhead between Symfony Expression Language and this library
Extends and sandbox mode.
Result
Lang | Op. Time | Overhead cost |
---|---|---|
Native PHP | 0.058µs | 0% |
Symfony EL | 0.461µs | +800% |
Twig lang | 0.187µs | +300% |
License
MIT License.