PHPER Framework用纯 Rust 开发 PHP 扩展
这是一个支持用纯 Rust 开发 PHP 扩展的框架,可以有效利用Rust生态,主要是对Zend API的封装。
PHPER 的意思是 PHP Enjoy Rust。
文档
教程
示例
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<()> {
// Get the first argument, expect the type `ZStr`, and convert to Rust utf-8
// str.
let name = arguments[0].expect_z_str()?.to_str()?;
// Macro which do php internal `echo`.
echo!("Hello, {}!\n", name);
Ok(())
}
/// This is the entry of php extension, the attribute macro `php_get_module`
/// will generate the `extern "C" fn`.
#[php_get_module]
pub fn get_module() -> Module {
// New `Module` with extension info.
let mut module = Module::new(
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION"),
env!("CARGO_PKG_AUTHORS"),
);
// Register function `say_hello`, with one argument `name`.
module.add_function("say_hello", say_hello).argument(Argument::by_val("name"));
module
}
评论
Leevel高性能 PHP 扩展开发框架
Leevel高性能PHP扩展开发框架Leevel是一个开源PHPC扩展开发框架,采用zephir编写,是为了解决使用框架带来性能下降的经典矛盾,Leevel是为了解决QueryPHP性能而开发,可以与
Leevel高性能 PHP 扩展开发框架
0
pgxr使用 Rust 开发 PostgreSQL 扩展函数
pgxr —— 使用 Rust 开发 PostgreSQL 扩展函数(存储过程)pgxr 是一个 R
pgxr使用 Rust 开发 PostgreSQL 扩展函数
0
pgxr使用 Rust 开发 PostgreSQL 扩展函数
pgxr——使用Rust开发PostgreSQL扩展函数(存储过程)pgxr是一个Rust的crate库,可以实现用Rust语言来编写PostgreSQL的扩展函数(相当于存储过程)。代码示例:#[m
pgxr使用 Rust 开发 PostgreSQL 扩展函数
0
sqlite-zstd用 Rust 编写的 SQLite 压缩扩展
sqlite-zstd 是 SQLite 的扩展,为 SQLite 提供透明的基于字典的行级压缩。这
sqlite-zstd用 Rust 编写的 SQLite 压缩扩展
0