mkdir -p ~/.ripht/src ~/.ripht/php
cd ~/.ripht/src
git clone https://github.com/php/php-src.git
cd php-src
./buildconf --force
./configure \
--prefix="$HOME/.ripht/php" \
--enable-embed=static \
--disable-zts
make -j"$(nproc)"
make installCargo.toml
[package]
name = "ripht-php-sapi"
version = "0.1.0"
edition = "2021"
[dependencies]
anyhow = "1.0.102"
ripht-php-sapi = "0.1.0-rc.3"build.rs
fn main() {
println!("cargo:rustc-link-lib=xml2");
println!("cargo:rustc-link-lib=sqlite3");
}src/main.rs
use ripht_php_sapi::prelude::*;
use ripht_php_sapi::CliRequest;
use std::path::Path;
fn main() -> anyhow::Result<()> {
let sapi = RiphtSapi::instance();
let script = Path::new("hello.php");
let ctx = CliRequest::new()
.build(script)?; // <- ExecutionContext
let result = sapi.execute(ctx)?;
println!("Status: {}", result.status_code());
println!("Body:\n{}", result.body_string());
Ok(())
}hello.php
<?php
echo "Hello from PHP via Rust!\n";RIPHT_PHP_SAPI_PREFIX="$HOME/.ripht/php" cargo build