determin1st/php-sm-test: example extension - Codeberg.org
This website requires JavaScript.
determin1st/php-sm-test
Watch
Star
Fork
You've already forked php-sm-test
Code
Issues
Pull requests
Releases
Activity
example extension
2 commits
1 branch
2 tags
37 KiB
41.1%
Batchfile
36.4%
Shell
16.6%
PHP
5.9%
based
Find a file
HTTPS
Download ZIP<br>Download TAR.GZ<br>Download BUNDLE
Open with VS Code
Open with VSCodium
Open with Intellij IDEA
determin1st
eb8bbfdf9d
i want to get back
2077-01-01 00:01:01 +00:00
.gitignore
i want to get back
2077-01-01 00:01:01 +00:00
build.bat
i want to get back
2077-01-01 00:01:01 +00:00
build.sh
i want to get back
2077-01-01 00:01:01 +00:00
main.c
i want to get back
2077-01-01 00:01:01 +00:00
main.h
i want to get back
2077-01-01 00:01:01 +00:00
README.md
i want to get back
2077-01-01 00:01:01 +00:00
test.php
i want to get back
2077-01-01 00:01:01 +00:00
UNLICENSE
i want to get back
2077-01-01 00:01:01 +00:00
README.md
Building php-sm Extensions
This guide describes how to set up a completely freestanding, portable compilation toolchain and build environment to develop PHP extensions utilizing the php-sm C ABI bridge mechanism.
How to Build
⑴ Get CLANG (x86_64) to serve as the foundational compiler toolchain:
For Linux environments: Retrieve a freestanding archive distribution from the kernel.org infrastructure (https://www.kernel.org/pub/tools/llvm/)—an optimized repack (~50MB) is available in the repository releases—or verify that an executable clang binary is already present within the workspace.
For Windows environments: Secure the official toolchain binaries from the LLVM project release channel (https://github.com/llvm/llvm-project/releases/).
Unpack the distribution package and append its internal /bin folder to the system PATH environment variable for quick command-line access.
⑵ Obtain the MSVC and Windows SDK system assets (Windows Only):
The freestanding compilation pipeline requires direct access to target platform isolation headers (include) and export stub descriptors (libs), which typically accompany Microsoft Visual Studio build tools.
A lightweight, stripped-down repack (~36MB) containing only the essential headers and library stubs can be downloaded directly from the repository releases page to avoid heavy toolchain installations.
⑶ Deploy the targeted PHP 8.3+ execution binary:
Ensure an operational PHP 8.3 or newer execution runtime environment is present on the system. PHP versions falling below 8.3 do not possess the internal structural layout required by the php-sm mapping mechanics. Verify that the php CLI execution command is bound within the system's PATH.
⑷ Secure the matching PHP development headers:
Obtain the engine source structure by executing: git clone https://github.com/php/php-src. Transition the local tree to match the targeted binary version using the checkout tagging mechanism (for example, git checkout tags/php-8.3.12 or git checkout tags/php-8.5.7).
Alternatively, these core header files are bundled directly within the official binary distributions as the "Development Pack" (the SDK to develop PHP extensions), containing the necessary Zend, main, and TSRM subdirectories.
⑸ Download the PHP-SM abstraction components:
Clone the primary freestanding integration engine C ABI bridge repository: git clone https://codeberg.org/determin1st/php-sm.
Clone the accompanying extension structural template skeleton repository: git clone https://codeberg.org/determin1st/php-sm-test.
Alternatively, these source configurations can be downloaded directly as archives through the web interface.
⑹ Update the local build script parameters:
Open the build configuration file matching the host operating system: build.bat on Windows or build.sh on Linux.
Modify the EXTENSION_NAME declaration string to assign the new custom module identity.
Update the underlying directory path variables (PHP_SOURCE, PHP_SM_SOURCE, and output paths) to target the exact absolute local directory locations established across the preceding steps.
⑺ Execute the local compilation process:
Trigger the execution build script inside the command shell terminal. The freestanding compiler configurations will bypass standard C runtime bloat and output a tightly optimized shared binary object (.so on Linux configurations or .dll on Windows configurations).
⑻ Configure and test the compiled extension module:
Enable autoloading permanently by updating the active configuration initialization file (php.ini) with the explicit assignment directive: extension=your_extension_name.
Alternatively, verify compilation integrity and run tests directly without modifying system configurations by executing the test runner with a transient injection flag: php -d extension=/path/to/binary.so test.php.