String Expression functions

What is it for?

This package extends the ExpressionLanguage component of Symfony to compile and evaluate arrays with custom functions.


composer require php-etl/string-expression-language


To use the functions provided in this package, you need to add the expression_language key to your plugin configuration and use the Kiboko\Component\ArrayExpressionLanguage\ArrayExpressionLanguageProvider Provider.

  - Kiboko\Component\StringExpressionLanguage\StringExpressionLanguageProvider

To determine that a value in your configuration will be a language expression, you must use the @ annotation.

foo: '@=dateTime(input["updated_at"], "YYYY-MM-ddTHH:ii:ss", "Europe/Paris")'

List of available functions

  • format( string format, mixed ...inputs ) : string formats a string using the sprintf syntax
  • trim( string input ) : string trims whitespaces from a string
  • replace( string search, string replace, string input ) : string replaces the search values in the string by the replace
  • fileName( string path ) : string extracts the file name from the path name
  • dateTime( string dateTime, string format, string timezone = 'UTC' ) : date Creates a date object from a formatted date
  • formatDate( date dateTime, string format ) : string Transforms a date object into a formatted date string