How to capture output from PHP extension using PHP-FPM

I have a custom C extension loaded in my PHP and inside the extension there the function does something like this

void a() { printf("abc"); } 

I can call a() without any problems in the CLI (command line) mode and get the abc output, as expected. But when I tried again in the Yii project in PHP-FPM mode, I could not get this output.

I'm sure:

  • The extension is loading.
  • The function call was successfully completed without errors.
  • PHP output buffering is disabled. I called ob_end_clean() twice before calling a() , the first call returned true , and the second returned false .

So my question is:

Should I get output from extensions in PHP-FPM mode?

If so, how can I capture the output, or please, give me some debugging tips.

+5
source share
1 answer

When PHP acts as a web server module, stdout is redirected to the terminal where the web server process started. Such a terminal is inactive on the production server, so any output that you send to stdout will be lost.

try php_printf () istead printf () one function

perhaps this article will help you https://devzone.zend.com/317/extension-writing-part-ii-parameters-arrays-and-zvals/

+5
source

Source: https://habr.com/ru/post/1275233/


All Articles