The framework that allows us to write PHP extensions using pure and safe Rust whenever possible.
Write PHP extensions in pure, safe Rust โ no C/C++ glue code required. Enjoy Rust's memory safety guarantees.
Leverage the entire Rust crate ecosystem directly in your PHP extensions. Use reqwest, serde, tokio, and more.
Register functions, classes, interfaces, enums, constants, INI settings and lifecycle hooks with an ergonomic API.
Supports PHP 7.0 through 8.5 across Linux and macOS, covering CLI and FPM SAPIs.
Create a new extension with just cargo new. Build with cargo build. No phpize needed for development.
Built-in integration test support via phper-test. Test your PHP extensions with familiar Rust test tools.
| Category | Item | Status |
|---|---|---|
| OS | Linux | โ |
| macOS | โ | |
| PHP Version | 7.0 โ 7.4 | โ |
| 8.0 โ 8.5 | โ | |
| PHP Mode | NTS | โ |
| SAPI | CLI | โ |
| FPM | โ | |
| Rust | 1.85+ | โ |
| Dependency | libclang 9.0+ | Required |
A hello world PHP extension in Rust โ it's that simple.
use phper::{echo, functions::Argument, modules::Module, php_get_module, values::ZVal};
/// The php function, receive arguments with type `ZVal`.
fn say_hello(arguments: &mut [ZVal]) -> phper::Result<()> {
let name = arguments[0].expect_z_str()?.to_str()?;
echo!("Hello, {}!\n", name);
Ok(())
}
/// This is the entry of php extension.
#[php_get_module]
pub fn get_module() -> Module {
let mut module = Module::new(
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION"),
env!("CARGO_PKG_AUTHORS"),
);
module.add_function("say_hello", say_hello)
.argument(Argument::new("name"));
module
}
The PHP Agent for Apache SkyWalking, which provides the native tracing abilities for PHP project.
The Jieba Chinese Word Segmentation Implemented in Rust Bound for PHP.