PHPackages                             masakielastic/hello-zig - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. masakielastic/hello-zig

ActivePhp-ext[Utility &amp; Helpers](/categories/utility)

masakielastic/hello-zig
=======================

PHP extension that returns Hello World from a Zig FFI library

v0.1.0(4mo ago)01↓93.8%MITM4PHP &gt;=8.1

Since Feb 25Pushed 4mo agoCompare

[ Source](https://github.com/masakielastic/php-ext-hello-zig)[ Packagist](https://packagist.org/packages/masakielastic/hello-zig)[ RSS](/packages/masakielastic-hello-zig/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

hello-zig
=========

[](#hello-zig)

Learning-focused sample of a PHP extension that calls Zig through a C ABI (FFI boundary).

Learning goals
--------------

[](#learning-goals)

- Understand how PHP extension C code calls a Zig function.
- Understand how Zig builds a static library consumed by PHP extension build.
- Understand how PIE metadata points to the extension build directory.

Project layout
--------------

[](#project-layout)

- `composer.json`: PIE metadata (`type: php-ext`, build path, extension name)
- `ext/config.m4`: phpize/autoconf build integration and Zig library linking
- `ext/hello_zig.c`: PHP function registration and call into Zig ABI
- `ext/zig/build.zig`: Zig static library build definition
- `ext/zig/src/hellozig.zig`: exported Zig function (`hellozig_message`)
- `ext/zig/src/hellozig.h`: C header consumed from `hello_zig.c`
- `ext/tests/001_hello_zig_hello.phpt`: runtime behavior test

How the call flow works
-----------------------

[](#how-the-call-flow-works)

1. PHP userland calls `hello_zig_hello()`.
2. PHP extension C code (`ext/hello_zig.c`) invokes `hellozig_message()`.
3. `hellozig_message()` is implemented in Zig and exported with C ABI.
4. Returned C string is sent back to PHP as a string result.

Install with PIE (from Packagist)
---------------------------------

[](#install-with-pie-from-packagist)

This package is intended to be installable from Packagist:

- `https://packagist.org/packages/masakielastic/hello-zig`

Example:

```
pie install masakielastic/hello-zig
php --ri hello_zig
php -r 'echo hello_zig_hello(), PHP_EOL;'
```

Expected output:

```
Hello World from Zig FFI!

```

Build and run (from clean state)
--------------------------------

[](#build-and-run-from-clean-state)

Prerequisites:

- `phpize` and PHP development headers
- Zig compiler (on `PATH`, or provided via `ZIG=/path/to/zig`)

```
cd ext
phpize
ZIG=/home/masakielastic/.local/zig-dev/zig ./configure --enable-hello-zig
make
php -dextension=modules/hello_zig.so -r 'echo hello_zig_hello(), PHP_EOL;'
```

Expected output:

```
Hello World from Zig FFI!

```

Run tests
---------

[](#run-tests)

```
cd ext
make test TESTS=tests/001_hello_zig_hello.phpt
```

What to edit while learning
---------------------------

[](#what-to-edit-while-learning)

- Change return text: `ext/zig/src/hellozig.zig`
- Add new PHP function: `ext/hello_zig.c` (function entry table + implementation)
- Add new Zig export and header declaration: `ext/zig/src/hellozig.zig` and `ext/zig/src/hellozig.h`
- Add regression test: `ext/tests/*.phpt`

Troubleshooting
---------------

[](#troubleshooting)

- `zig command not found`:
    - Pass explicit path: `ZIG=/absolute/path/to/zig ./configure --enable-hello-zig`
- Build errors after file moves:
    - Re-run from clean build dir: `phpize` then `./configure` then `make`
- Extension not loading:
    - Confirm `.so` exists at `ext/modules/hello_zig.so`
    - Use absolute path in `-dextension=...`

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance76

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

129d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4f41eb895541ecf23ae0a4316429c3b01872a8a2c45ecb95af81ac60461f7731?d=identicon)[masakielastic](/maintainers/masakielastic)

---

Top Contributors

[![masakielastic](https://avatars.githubusercontent.com/u/49705?v=4)](https://github.com/masakielastic "masakielastic (5 commits)")

---

Tags

ffiphp-extensionzig

### Embed Badge

![Health badge](/badges/masakielastic-hello-zig/health.svg)

```
[![Health](https://phpackages.com/badges/masakielastic-hello-zig/health.svg)](https://phpackages.com/packages/masakielastic-hello-zig)
```

###  Alternatives

[jonthornton/jquery-timepicker

A javascript timepicker plugin for jQuery inspired by Google Calendar.

1.9k41.5k1](/packages/jonthornton-jquery-timepicker)[splitsoftware/split-sdk-php

Split SDK for PHP

161.4M2](/packages/splitsoftware-split-sdk-php)[bayfrontmedia/php-array-helpers

Helper class to provide useful array functions.

1414.6k26](/packages/bayfrontmedia-php-array-helpers)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
