Help adding PHP support

Hey everyone,

I’m working on adding PHP as an SDK for my platform, but I haven’t worked with PHP since version 3. One of the challenges I’m facing is how to properly handle callbacks from FFI when subscribing to events.

The PHP FFI documentation mentions that callbacks are not recommended and can cause memory leaks. Without safe callback handling, it seems like I’m limited to making all calls synchronous, as implementing an async/await approach would be risky or impossible.

If you’ve worked with FFI in PHP, how do you typically handle callbacks in a way that’s safe and avoids memory leaks? Is there a standard approach or library for this? I’d love to hear your thoughts or see any examples of best practices.

Thanks in advance for your help!