4.x is outdated, please check the latest version 22.x

Latest version: pecl install openswoole-22.1.2


<?php Swoole\Coroutine\FastCGI\Client::call(string $url, string $path, mixed $data = '', float $timeout = -1): string



The FastCGI address, where the FPM process is monitoring, could be or a UnixSocket like unix:/tmp/php-cgi.sock.


The actual file that will be executed on the FPM side, usually a PHP file.


Any data which you want to send, a string or array etc.


The default is to never time out (-1) but you may set a timeout in seconds. So 1.5 means 1.5 seconds.


Returns the response from the FPM request, returns the actual response body. You can catch any errors by using a try-catch with this client.


The FastCGI call() method is a static helper used to make it easy to execute quick requests via FastCGI and PHP-FPM, internally it handles setting up the client, attaching data and sorting out request and response objects to use. Basically, a wrapper to the main FastCGI client object.

Either this method will return the body of the server response or an error will be thrown under the exception Swoole\Coroutine\FastCGI\Client\Exception, you can use a try-catch to process errors.



// /tmp/greeter.php

echo 'Hello ' . ($_POST['who'] ?? 'World');

// /tmp/swoole-fastcgi-client.php

    echo Swoole\Coroutine\FastCGI\Client::call(
        '',       // PHP-FPM address, can also be a socket like unix://path/to/fpm.sock
        '/tmp/greeter.php',     // The PHP script to be executed, use an absolute path
        ['who' => 'Swoole']     // POST Request Data as an array

Checkout the main FastCGI Client page for more details and examples.

Last updated on August 31, 2022