whynot-0.2.0 has been yanked.
whyNot πβ‘οΈπ¦
Rust β PHP bridge that lets you call PHP functions directly from Rust, capture return values, printed output, and exceptions β with async support via threads or Tokio.
β¨ Features
- Call any PHP function from Rust
- Capture both return values and printed output
- Structured exception handling (
PhpException) - Objects returned with class + fields
- Persistent runtime (globals/includes survive across calls)
includeandevalsupport- Async via threads (
call_async_with_cfg) - Async/await via Tokio (
--features async_tokio)
π Getting Started
Install
To install you can run:
Or add to your Cargo.toml:
[]
= "0.1.0"
Requirements
- PHP CLI (
php) available in PATH php/runner.phpandphp/bootstrap.phpincluded in your project
π Usage
Basic call
use ;
Exceptions
let boom = rt.call.unwrap;
if let Some = boom.exception
Async (threads)
use ProcRuntime;
let h1 = call_async_with_cfg;
let h2 = call_async_with_cfg;
println!;
println!;
Async/await (Tokio)
Enable the feature:
Example:
async
π Project Layout
whynot/
Cargo.toml
src/
lib.rs
value.rs
macros.rs
process.rs
embedded.rs
async_tokio.rs
php/
runner.php
bootstrap.php
examples/
call_any.rs
async_calls.rs
tokio_async.rs
π Roadmap
- Function calls, output capture, exceptions
- Objects serialization
- Includes, eval
- Threaded async
- Tokio async/await
- Embedded Zend runtime (inβprocess)
- Resource/extension support
- Automatic Rust β PHP struct mapping
- Publish crate to crates.io
π€ Contributing
Pull requests welcome. Please open issues for bugs, feature requests, or questions.