With the API protocol, you need to explicitly specify the names of all arguments. Also, while not required by the protocol, to allow for better copy&pate-ability from API to console, PEAR2_Net_RouterOS requires commands be prefixed with “/” to indicate absolute path.
If you press “?” after a command, you’ll see the names of all arguments, with “<” and “>” around those that have names that can be omitted from the command line.
So, with that in mind, the specific command you’re looking for is:
$client->sendSync(new RouterOS\Request('/ip hotspot user set password="12345" numbers=test'));
(The name “numbers” can be omitted from the command line, but not from API; Paste it back into the command line, and you’ll see it has the same effect)
If you’re going to let user input into the command though, you should use the Request object’s setArgument() method, so f.e.
$setRequest = new RouterOS\Request('/ip hotspot user set');
$setRequest
->setArgument('numbers', $_POST['username'])
->setArgument('password', $_POST['password']);
$client->sendSync($setRequest);
Otherwise, you’re setting yourself up for a command injection (which can have different consequences depending on the command; In this scenario, a malicious user could use it to set their profile to something they aren’t allowed to or set the password for a different user, and then login as them).
The particular example of setting a hotspot user’s password is part of the MikroTik wiki page, and this is where I tend to put the more “full featured” examples, while the GitHub wiki has the “client features” examples. To put it another way, the GitHub wiki is meant to be read like you read a programming language tutorial, while the MikroTik wiki is intended to be read like you read programming blog posts.
If you have any suggestions for other full featured examples, I’ll be happy to hear them and will most likely add them to the MikroTik wiki. Or even better, if you have a blog or anything and write your own tutorial(s), I’ll definitely link to it (possibly from both wikis).