Skip to content

swoole/phpx

Repository files navigation

Swoole Logo

Twitter Discord Build Status License Latest Release Codecov

C++ wrapper for Zend API

Requirements

  • PHP 8.1 or later
  • Linux/macOS/Windows
  • GCC 4.8 or later
  • Composer

Build libphpx.so

# 标准构建(Release 模式)
cmake .
make -j 4
sudo make install
sudo ldconfig

Debug 模式(用于排查问题)

# 清理之前的构建
cmake --build . --target clean

# 配置 Debug 模式(包含调试符号和运行时检查)
cmake -DCMAKE_BUILD_TYPE=Debug .

# 编译
make -j 4
sudo make install
sudo ldconfig

Debug 模式特性:

  • ✅ 生成完整的调试符号
  • ✅ 禁用编译器优化,便于单步调试
  • ✅ 启用运行时错误检查
  • ✅ 更详细的编译输出信息

Create Project

# extension
composer create-project swoole/phpx-ext test

Generate ArgInfo & Function Entires

php vendor/swoole/phpx/bin/gen_stub.php your_stub_dir

Build extension

cd test
cmake .
make -j 4
make install

Load your extension

Edit php.ini, add extension=test.so

Run

php echo.php

About

C++ wrapper for Zend API

Resources

License

Stars

Watchers

Forks

Contributors