Skip to content

phpz 0.1.0

Latest

Choose a tag to compare

@github-actions github-actions released this 23 Nov 16:06
· 3 commits to dev since this release

phpz 0.1.0 is the first release of phpz, a Zig framework for building native PHP extensions. Declare functions and classes in a PHP stub, implement them in Zig, and load the compiled extension into PHP.

Highlights

  • Export typed Zig functions and methods to PHP. Scalar arguments follow PHP’s weak and strict typing rules. Look up Zend class entries from Zig and expose your own PHP classes, properties, and methods.
  • Work with PHP strings, arrays, and request memory from Zig. Bailout guards let handlers clean up native resources when a Zend bailout would otherwise skip Zig cleanup.
  • Build shared extensions or compile an extension into PHP. Experimental custom SAPI support lets a Zig executable host the PHP runtime.
  • Generate a project with the standalone phpz_skel.php release asset. It selects phpz 0.1.0 by default and includes a working extension and PHPT tests.

Toolchain and platforms: Zig 0.17.0 and PHP 8.2–8.6 (NTS and ZTS). Linux and macOS support x86_64 and aarch64. Windows supports x64 with the MSVC ABI.

Quick start

With Zig, PHP CLI, and matching PHP development headers installed, generate an extension on Linux or macOS:

curl -fsSL https://github.com/happystraw/phpz/releases/download/0.1.0/phpz_skel.php | php -- --ext my_php_extension

On PHP 8.2, download the generator and run it locally:

curl -fsSLO https://github.com/happystraw/phpz/releases/download/0.1.0/phpz_skel.php
php phpz_skel.php --ext my_php_extension

Build and call the generated extension:

cd my_php_extension
zig build
php -n -dextension=./modules/my_php_extension.so -r 'echo greet("Zig"), PHP_EOL;'

Expected output: Hello, Zig!

The English and Chinese guides cover installation, Windows builds, and extension development. The Zig API reference is available alongside them. English guide · 中文文档 · Zig API reference

New Contributors


This initial release was developed by @happystraw with contributions from @TrixNEW.