Skip to content

PHP

This module allows executing custom PHP code within a workflow. The user’s code is automatically wrapped in a run($data) function that receives the flow data as an associative array via stdin in JSON format. The script runs as an independent PHP child process using a temporary file, providing isolation from the main Node.js process. The result must be a PHP associative array that is serialized as JSON. It is ideal for leveraging existing PHP libraries, performing calculations that are more natural in PHP, or integrating business logic written in PHP.

ParameterTypeRequiredDescription
scriptstringYesPHP code to execute inside the run($data) function. Do not include the function declaration or PHP tags. The code must return an associative array.
{
"nextModule": "siguiente_modulo",
"data": {
"suma": 150,
"cantidad": 5
}
}
{
"script": "return [\n \"suma\" => array_sum($data[\"valores\"] ?? []),\n \"cantidad\" => count($data[\"valores\"] ?? [])\n];"
}
  • Requires PHP to be installed and available in the system PATH
  • The script runs as an independent child process (child_process.spawn)
  • Input data is passed via stdin as JSON
  • The result must be a PHP associative array (converted to JSON with json_encode)
  • The temporary file is automatically deleted after execution
  • If the PHP script returns an error or a non-zero exit code, the promise is rejected
  • Does not have direct access to the database or workflow memory from PHP
  • The temporary file name includes a UUID to avoid collisions
  • pythonRunner (execute Python code)
  • executescript (execute JavaScript with access to the workflow context)
  • evaluateExpression (evaluate simple JavaScript expressions)