New Feature: What the Fibers extension can do for you
summary
Compares using PHP FFI to writing a native PHP extension by wiring C DuckDB into PHP: builds a small in-memory DuckDB demo via FFI and via a compiled extension, measures overhead (FFI ~6 percent slower once headers are parsed), and shows FFI avoids compiling but requires manual pointer and memory management (malloc/free), leading to potential leaks; extension needs lots of boilerplate and native debugging with gdb/valgrind/ASan, Docker used for reproducible builds; conclusion: FFI works for prototyping and large-C work, extensions for tighter control.
AI-written summary · about
chapters (20)
- 0:00Intro
- 0:40What is FFI?
- 0:55What problems does FFI solve?
- 2:18Limitation of FFI
- 3:30Talk is cheap, show me the code!
- 4:06PHP vs C - function definition
- 5:11Header files
- 6:25Preprocessor - it can be extremely powerful!
- 7:30DuckDB - introduction
- 8:23DuckDB - bindings
- 8:39DuckDB - example
- 17:21Extension development - prerequisites
- 18:26Extension development - generate skeleton
- 18:52Extension development compilation
- 19:10Define API a little surprise
- 19:46Heart of extension - zend_module_entry
- 24:18Macro expansion
- 31:16Performance - numbers
- 32:20Comparison - common
- 36:39Which one is better?
related talks
41mNew Feature: What the Fibers extension can do for you
34mFFI: New horizons for PHP
43mWhat can PHP Foreign Function Interface do for you?
48mIntroduction to PHP Extensions
51mPHP Fibers
44mPHP Extension Development with C++
28mA field guide to writing PHP extensions
42mBeyond OOP: Developing PHP Extensions ... in PHP!
