Custom formatter (php) : syntax error, unexpected 'namespace' (T_NAMESPACE)

Hello,
In the process of putting together a custom formatter, all seems to work fine within wappler, however, when I upload to my development environment to test the functionality, I get this:

{"code":0,"file":"\/volume1\/web\/instance_1\/extensions\/server_connect\/formatters\/custom.php","line":3,"message":"syntax error, unexpected 'namespace' (T_NAMESPACE)","trace":"#0 \/volume1\/web\/instance_1\/dmxConnectLib\/dmxConnect.php(115): require()\n#1 [internal function]: {closure}('lib\\\\core\\\\Parser')\n#2 \/volume1\/web\/instance_1\/dmxConnectLib\/lib\/App.php(35): spl_autoload_call('lib\\\\core\\\\Parser')\n#3 \/volume1\/web\/instance_1\/index.php(4): lib\\App->__construct()\n#4 {main}"}

Line 3 is just namespace lib\core; The whole PHP code is as follows:

<?php 
​
namespace lib\core;
  
function formatter_graphifyForRecipients($val) {
  $recipients = explode(",",$val);
  $json = "";
  foreach ($recipients as $index => $recipient) {
    if ($index > 0) {
      $json .= ",";
    }
    $json .= "{\"emailAddress\": {\"address\": \"$recipient\"\}}";
  }
  return $json;
​
}

The hsjon file is as follows:

[
    {
    type: 'method_graphifyForRecipients',
    groupTitle : 'Custom Formatters',
    groupIcon : 'fas fa-lg fa-hammer comp-data',
    addTitle: 'GRAPHify for Recipients',
    title : 'GRAPHify for Recipients',
    icon : 'fa fa-lg fa-font',
    state : 'opened',
    help : 'Builds and array to send to a list of recipients',
    properties : []
  }
]

I deleted DmxConnectLib and let Wappler recreate it, however, when I upload it, I see this on the terminal window:

Wappler version is 3.9.9 on a Windows 10 machine.

Any advice?

Community Page
Last updated: