whynot 0.1.1

Rust ↔ PHP bridge: call PHP functions from Rust, capture return values, output, and exceptions.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use whynot::{new_runtime, RuntimeConfig, RuntimeKind, PhpValue};
use whynot::{php_call, php_eval, php_include};

fn main() {
    let cfg = RuntimeConfig { debug: false, ..Default::default() };
    let mut rt = new_runtime(RuntimeKind::Process(cfg)).unwrap();

    let r1 = php_call!(rt, hello()).unwrap();
    println!("hello: output={:?} result={:?}", r1.output, r1.result);

    let r2 = php_call!(rt, greet("Milton")).unwrap();
    println!("greet: output={:?} result={:?}", r2.output, r2.result);

    let r3 = php_eval!(rt, "print('eval works'); return 42;").unwrap();
    println!("eval: output={:?} result={:?}", r3.output, r3.result);

    let _ = php_include!(rt, "php/bootstrap.php").unwrap();
}