本文使用 Solder
库来实现PHP扩展程序,它是基于 php-rs
库的试验性项目,实现了php扩展的函数处理。 满足了字符串和数字类型基本要求。
soder 源库地址为 github , 这里使用的是 fork 的库, github.com/erasin/solder。
2020-09-17 : 项目 XX/php-rust 中提供了更多的类型处理。简化函数注册流程。
创建项目
使用 cargo 来创建项目,然后创建编译配置文件.cargo/config
cargo new --lib rs-tool
cd rs-tool
mkdir .cargo
touch config
编辑 .cargo/config
,遵循toml格式。
[build]
rustflags = ["-C", "link-args=-Wl,-undefined,dynamic_lookup"]