- Use
ext-php-rsfor PHP 8.2+ native extensions. Use#[php_class]and#[php_function]macros. - Map Rust types to PHP via
FromZval/IntoZvaltraits. ReturnPhpResult<T>for fallible operations. - Map Rust errors to PHP exceptions:
PhpException::from(...)with specific classes (InvalidArgumentException,RuntimeException). - Use
#[php_method]for class methods. Implement__constructfor PHP constructors. - Build with
cargo build --release. Load extension viaphp.ini(extension=your_ext.so) or PECL distribution. - Test from PHP using PHPUnit. Verify extension loading with
php -m | grep extension_name. - Use
ZendClassObject<T>for wrapping Rust structs as PHP objects. - PHP uses reference counting — avoid circular references in wrapped Rust structs. Implement
Dropfor cleanup. - PHP is single-threaded per request — offload CPU-intensive work to Rust, return results synchronously.
- Keep PHP extension thin — business logic in Rust, PHP provides typed interface.
- Anti-patterns: panics in PHP functions, blocking operations without timeout, raw pointer manipulation.
Ext PHP Rs Bindings
ext-php-rs conventions for building PHP 8.2+ native extensions from a Rust core: php_class/php_function macros, Zval conversion, PhpException mapping, php.ini loading, and PHPUnit testing. Load when generating or reviewing ext-php-rs PHP bindings for a Rust library.
Ext PHP Rs Bindings by goldziher · 403d462
npx skillmds@latest add goldziher/ext-php-rs-bindings File contents
---name: ext-php-rs-bindingsdescription: ext-php-rs conventions for building PHP 8.2+ native extensions from a Rust core: php_class/php_function macros, Zval conversion, PhpException mapping, php.ini loading, and PHPUnit testing. Load when generating or reviewing ext-php-rs PHP bindings for a Rust library.---- Use `ext-php-rs` for PHP 8.2+ native extensions. Use `#[php_class]` and `#[php_function]` macros.- Map Rust types to PHP via `FromZval`/`IntoZval` traits. Return `PhpResult<T>` for fallible operations.- Map Rust errors to PHP exceptions: `PhpException::from(...)` with specific classes (`InvalidArgumentException`, `RuntimeException`).- Use `#[php_method]` for class methods. Implement `__construct` for PHP constructors.- Build with `cargo build --release`. Load extension via `php.ini` (`extension=your_ext.so`) or PECL distribution.- Test from PHP using PHPUnit. Verify extension loading with `php -m | grep extension_name`.- Use `ZendClassObject<T>` for wrapping Rust structs as PHP objects.- PHP uses reference counting — avoid circular references in wrapped Rust structs. Implement `Drop` for cleanup.- PHP is single-threaded per request — offload CPU-intensive work to Rust, return results synchronously.- Keep PHP extension thin — business logic in Rust, PHP provides typed interface.- Anti-patterns: panics in PHP functions, blocking operations without timeout, raw pointer manipulation.
goldziher/ai-rulez/tree/main/internal/builtins/bindings/ext-php-rs/skills/ext-php-rs-bindings commit 403d462abd
Frequently asked questions
Run npx skillmds@latest add goldziher/ext-php-rs-bindings in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
ext-php-rs conventions for building PHP 8.2+ native extensions from a Rust core: php_class/php_function macros, Zval conversion, PhpException mapping, php.ini loading, and PHPUnit testing. Load when generating or reviewing ext-php-rs PHP bindings for a Rust library. It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
goldziher (@goldziher) published this skill. Their other Agent Skills are listed on their SkillMD profile.