swoole/make-library

Maintainers

👁 Tianfeng.Han

Package info

github.com/swoole/make-library

Homepage

Type:utils

pkg:composer/swoole/make-library

Statistics

Installs: 950

Dependents: 0

Suggesters: 0

Stars: 5

Open Issues: 0

v1.0.1 2022-12-16 03:39 UTC

Requires

  • php: >=8.0

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

Apache-2.0 3b16e84fb5c0e735cdc9d0aed19c7e3de64611d1

  • Tianfeng Han <rango.woop@swoole.com>

This package is auto-updated.

Last update: 2026-06-16 11:57:27 UTC


README

Convert PHP code to C/C++ header file

Edit __init__.php

Edit the __init__.php file in the source code directory, the make-library script will read this file to configuration.

# 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 #
 ]
];

Make header file

composer require swoole/make-library
vendor/bin/make-library.php ./src

The first parameter is the source code path, there must exist __init__.php in this directory.

Loader library in php extension

#include "php_{$libaryName}_library.h"

// execute in RINIT function
php_{$libaryName}_load_library();