https://github.com/arshidkv12/zig-php
PHP extension written in Zig
https://github.com/arshidkv12/zig-php
php php-zig zig
Last synced: 26 days ago
JSON representation
PHP extension written in Zig
- Host: GitHub
- URL: https://github.com/arshidkv12/zig-php
- Owner: arshidkv12
- License: gpl-2.0
- Created: 2024-01-15T13:30:05.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-30T15:18:33.000Z (about 1 year ago)
- Last Synced: 2024-11-30T16:25:16.699Z (about 1 year ago)
- Topics: php, php-zig, zig
- Language: Zig
- Homepage:
- Size: 425 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-zig - zig-php🗒️PHP extension written in Zig
- awesome-zig - arshidkv12/zig-php - Write PHP extension in Zig. (FFI Bindings / Linker)
README
# PHP Zig Extension Skeleton
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.
## Requirements
- **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](https://ziglang.org/download/).
- **GNU Make**: Required to build the extension.
- **Autotools**: Required for `phpize` and `./configure`.
### System Dependencies (Linux/macOS)
```bash
sudo apt-get install php-dev make autoconf
# Or for macOS using Homebrew
brew install autoconf make php
```
[](https://youtu.be/Q2KQDQWcXZU)
## Installation Instructions
1. Clone the repository:
```
git clone https://github.com/arshidkv12/zig-php.git
cd zig-php
```
2. Install PHP development headers and dependencies, such as phpize.
3. Run the build process.
## Building the Extension
Edit build.zig file. Add correct cwd_relative php path.
To build it:
1. `zig build`
2. `phpize`
3. `./configure`
4. `make`
To test it:
`php -d extension=./modules/my_php_extension.so -r "echo hello_world();"`
Should output:
`Hello from ZIG!`