Skip to main content

Module ffi

Module ffi 

Source
Expand description

Raw FFI bindings to PHP embed SAPI and our C helper functions.

We use manual declarations rather than bindgen for the POC — only the functions we actually call are declared here.

Structs§

folk_request_context
Per-request context passed from Rust to our SAPI callbacks. Must match folk_request_context_t in php_embed_helper.c.
zval
Opaque PHP zval (Zend value). 16 bytes on 64-bit. We never access fields directly — only through our C helper functions.

Constants§

IS_ARRAY
IS_DOUBLE
IS_FALSE
IS_LONG
IS_NULL
IS_OBJECT
IS_STRING
IS_TRUE
IS_UNDEF

Functions§

folk_array_add_array
Add a sub-array to a PHP array by key.
folk_array_add_long
Add a long to a PHP array by key.
folk_array_add_string
Add a string to a PHP array by key.
folk_array_append_string
Append a string to a PHP array (numeric index).
folk_array_count
Get array element count.
folk_array_get_long
Read long from PHP array by key.
folk_array_get_string
Read string from PHP array by key.
folk_array_index_string
Get string from array by numeric index.
folk_array_init
Create a new PHP array zval.
folk_call_function_protected
Call function with SIGSEGV protection. Returns -3 on SIGSEGV.
folk_call_function_safe
folk_call_with_array
Call PHP function with single array argument. Returns -3 on SIGSEGV.
folk_call_with_binary
Call PHP function with raw binary args (no base64). Returns -3 on SIGSEGV.
folk_clear_output
folk_eval_string_protected
Eval with SIGSEGV protection. Returns -3 on SIGSEGV.
folk_eval_string_safe
folk_execute_script_safe
folk_free_buffer
Free a buffer allocated by folk_call_with_binary.
folk_free_output
folk_get_output
folk_install_output_handler
Install our output capture handler into the embed SAPI module. Only needed for legacy embed SAPI (boot()), not for custom SAPI.
folk_is_zts
Returns 1 if ZTS build, 0 if NTS.
folk_request_context_clear
Clear the current request context (after request_shutdown).
folk_request_context_set
Set the current request context (before request_startup).
folk_request_shutdown_safe
folk_request_startup_safe
folk_response_clear
Clear response state (between requests).
folk_response_free
Free all response resources (thread shutdown).
folk_response_header_count
Get the number of captured response headers.
folk_response_header_get
Get a response header by index. Sets *out_len.
folk_response_status_code
Get the response HTTP status code.
folk_sapi_init
Initialize PHP with our custom Folk SAPI (replaces php_embed_init).
folk_sapi_init_with_ini
Initialize PHP with custom INI overrides (double-NUL terminated).
folk_sapi_shutdown
Shutdown our custom SAPI (replaces php_embed_shutdown).
folk_signals_restore
Restore saved signal handlers (call after folk_sapi_init).
folk_signals_save
Save current signal handlers (call before folk_sapi_init).
folk_sigsegv_handler_install
Install SIGSEGV handler for worker thread protection.
folk_thread_init
Allocate TSRM context for current thread (ZTS). Returns NULL on NTS.
folk_thread_set_ctx
Set TSRM context for current thread.
folk_thread_shutdown
Free TSRM context.
folk_zval_dtor
folk_zval_get_long
folk_zval_get_string
folk_zval_set_string
folk_zval_type
folk_zval_undef
php_embed_init
php_embed_shutdown