Invoke Rust from PHP


I would like to write a program in Rust that takes a string as its argument, and returns a string.

I want to invoke this program from PHP.

For example something like this (I don't know the correct syntax):

fn main(input: String) -> String {
    return format!("{} Something", input);

include 'program';

echo main('Some input');

I haven't used PHP for ages, but these functions might help you:

You would need to compile the Rust program, place the binary somewhere, and then you can invoke it using exec or shell_exec from PHP.

(Maybe someone else with better PHP knowledge can give better advice.)

Thank you!