Invoke Rust from PHP

Hello,

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);
}
<?php

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!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.