swoole / make-library
v1.0.1
2022-12-16 03:39 UTC
Requires
- php: >=8.0
This package is auto-updated.
Last update: 2024-09-16 08:23:35 UTC
README
将 PHP
代码转换为 C/C++
头文件
编辑 __init__.php
在源代码目录中编辑 __init__.php
文件,make-library
脚本将读取此文件进行配置。
# file: __init__.php <?php return [ 'name' => 'swoole', // Library name 'checkFileChange' => false, // Check if there are uncommitted changes in the git repository 'output' => '/your/c_header_file_path', // Generated C/C++ header file path 'stripComments' => true, // Whether to keep comments /* Notice: Sort by dependency */ 'files' => [ # <basic> # 'constants.php', # <std> # 'std/exec.php', # <core> # 'core/Constant.php', # ... more files # ] ];
生成头文件
composer require swoole/make-library
vendor/bin/make-library.php ./src
第一个参数是源代码路径,此目录中必须存在 __init__.php
。
在 PHP 扩展中加载库
#include "php_{$libaryName}_library.h" // execute in RINIT function php_{$libaryName}_load_library();