Build and test

Integration with the PHP build system

The integration files let PHP’s build system invoke Zig to compile an extension.

Generate integration files

Generate the skeleton with --with-php-build-system for config.m4, config.w32, Makefile.frag and the module header.

Unix shared extensions

In the generated extension directory, run:

phpize
./configure --enable-my_php_extension
make

For my_php_extension the default mode is ReleaseSafe. Override it with MY_PHP_EXTENSION_ZIG_FLAGS.

Built-in extensions

Place the project under ext/ in the PHP source tree and enable the extension when configuring PHP.

zig build -Dshared=false produces the static library. Link it into PHP and enable its module to complete a built-in build. Static archives cannot be loaded through extension=.