This project provides a skeleton for building a PHP extension written in Zig. The goal of this project is to leverage Zig's performance and safety features within the PHP ecosystem. This guide will walk you through how to build and test the extension.
- PHP: You need a PHP installation with the ability to compile extensions (e.g.,
phpize
). - Zig: Install the Zig programming language from Zig's official site.
- GNU Make: Required to build the extension.
- Autotools: Required for
phpize
and./configure
.
sudo apt-get install php-dev make autoconf
# Or for macOS using Homebrew
brew install autoconf make php
- Clone the repository:
git clone https://github.com/arshidkv12/zig-php.git
cd zig-php
- Install PHP development headers and dependencies, such as phpize.
- Run the build process.
To build it:
zig build
phpize
./configure
make
To test it:
php -d extension=./modules/my_php_extension.so -r "echo hello_world();"
Should output:
Hello from ZIG!