使用rust创建php扩展
windows
- 安装Visual Studio的 clang和llvm包
- 设置环境变量LIBCLANG_PATH = ‘Microsoft Visual Studio\2022\Community\VC\Tools\Llvm\x64\bin’ 注意是32还是64位
- 设置环境变量 PHP=php.exe 或者 在PATH中可以找到php.exe
- 跟着文档做 https://davidcole1340.github.io/ext-php-rs/getting-started/hello_world.html
- cargo build
- php ‘-dextension=.\target\debug/hello_world.dll’ -m
Linux
- 跟着错误提示处理
- 如果有多个版本, 注意环境变量 PHP PHP_CONFIG
- cargo build
- php ‘-dextension=.\target\debug/hello_world.dll’ -m 注意php的版本和编译版本