1use anyhow::Result;
2use whynot::{new_runtime, PhpRuntime, PhpValue, RuntimeConfig, RuntimeKind};
3
4fn main() -> Result<()> {
5 let cfg = RuntimeConfig { debug: true, ..Default::default() };
6 let mut rt = new_runtime(RuntimeKind::Process(cfg))?;
7
8 let hello = rt.call("hello", &[])?;
9 println!("hello.output = {:?}", hello.output);
10 println!("hello.result = {:?}", hello.result);
11
12 let greet = rt.call("greet", &[PhpValue::from("Milton")])?;
13 println!("greet.output = {:?}", greet.output);
14 println!("greet.result = {:?}", greet.result);
15
16 let add = rt.call("add", &[7.into(), 5.into()])?;
17 println!("add.output = {:?}", add.output);
18 println!("add.result = {:?}", add.result);
19
20 let user = rt.call("make_user", &[PhpValue::from("Alice"), PhpValue::from(30)])?;
21 println!("user.output = {:?}", user.output);
22 println!("user.info = {:?}", user.info);
23 println!("user.result = {:?}", user.result);
24
25 let boom = rt.call("risky", &[])?;
26 if let Some(ex) = boom.exception.as_ref() {
27 println!("exception.class = {}", ex.class);
28 println!("exception.message = {}", ex.message);
29 println!("exception.code = {}", ex.code);
30 println!("exception.trace = {}", ex.trace);
31 println!("exception.output = {}", boom.output);
32 }
33
34 Ok(())
35}