Claude Cursor Skill

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.

LLM Mart · 0 points · 0 views 0 listing impressions 0 install-command copies
Virus-scanned Reviewed automatically before listing.

Full trust report

Download goldziher-ai-rulez-internal_builtins_bindings_ext-php-rs_skills_ext-php-rs-bindings-ca967ad.zip · 0 KB
Part of goldziher/ai-rulez — 151 skills

Install

skills CLI npx skills add https://github.com/Goldziher/ai-rulez/tree/main/internal/builtins/bindings/ext-php-rs/skills/ext-php-rs-bindings
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install goldziher-ai-rulez@llmmart
Git git clone https://github.com/Goldziher/ai-rulez.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole goldziher/ai-rulez collection as a plugin from our marketplace. Git is the plain clone.

Skill manifest

  • 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.
Files (ai-rulez)
  • SKILL.md 1.4 KB
    ---
    name: ext-php-rs-bindings
    description: "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.
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.

Related