Download the PHP package leongrdic/smplang without Composer

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

SMPLang

release php-version license run-tests

try

SMPLang is a simple expression language written in PHP. It can be considered similar to PHP's native eval() function but SMPLang has its own syntax and the expressions are evaluated in sort-of a sandbox with access to only vars and functions/closures that you pass into it.

The language is partly inspired by Symfony Expression Language but there are some major differences like array unpacking, named arguments and easier function definition, thus SMPLang may not be a replacement for some use cases.

Install:

To use SMPLang, create a new instance of the \Le\SMPLang\SMPLang class and pass in an associative array of vars that you want to use in your expressions.

You can then call the evaluate() method on the instance, passing in an expression string. This will return the result of the expression.

Optionally, you can pass in an associative array to the second parameter to provide additional local vars to use in the expression:

Vars passed this way will override vars passed in the constructor and will only be available in this specific expression, in case multiple expressions are evaluated from the same object.

In case of an exception, \Le\SMPLang\Exception will be thrown with a short description of the error.

Expression syntax

Vars are accessed by only their name. If a var is not defined in neither constructor or evaluate(), an exception will be thrown.

Supported literals

Arrays

Array definition: [element1, element2]

Associative array definition: ["key": element, string_variable: element2]

You can define associative arrays with dynamic keys by using string vars in place of keys.

Array unpacking is supported: [element1, ...array, ...array2]

Access array elements using either of the following syntaxes: array.key.0 or array['key'][0] (which allows for dynamic array access).

Objects

Object definition: {foo: "bar", baz: 23} (supports array unpacking)

Object property access: object.property

Object method call: object.method(parameters)

Function / closure call

Call a function or closure var: closure_var(param1, param2).

Named arguments: foo(search: value, count: 1).

Function / closure calls support array unpacking: bar(param1, ...array, ...array2)

Arithmetic operators

Comparison operators

Logical operators

String concatenation

Ternary expressions

Examples

try

try

try

try

try


All versions of smplang with dependencies

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

Loading the files please wait ....