Swoole Coroutine FastCGI Proxy

Notice: the documentation is suitable for PHP extension swoole until v4.7.1, we only support PHP extension openswoole from v4.7.1

Swoole Coroutine FastCGI Proxy can be used to communicate with FastCGI servers like PHP-FPM. This proxy allows you to setup a Swoole HTTP server for example and perform a proxy pass over to a PHP-FPM server, allowing you to use a Swoole server in front for better scaling and performance. The proxy class is a wrapper around the Swoole FastCGI client, it will handle translating the request and response and communication for you. The main function that is most likely to be used is the $proxy->pass() function, this is what handles all the proxy requests/communication.

Even though the main function that you will predominately use is pass() this wrapper class comes with a range of other functions as well, some of these functions can be used to chain together a proxy pass to meet your requirements, for example, to set a timeout with the proxy pass you can do $proxy->withTimeout(3)->pass(...).

To understand more about this class and its methods you can view the source code on GitHub.

Version: Swoole: 4.5.0+

Available Methods

  • Swoole\Coroutine\FastCGI\Proxy::__construct
  • Swoole\Coroutine\FastCGI\Proxy->withTimeout
  • Swoole\Coroutine\FastCGI\Proxy->withHttps
  • Swoole\Coroutine\FastCGI\Proxy->withIndex
  • Swoole\Coroutine\FastCGI\Proxy->getParam
  • Swoole\Coroutine\FastCGI\Proxy->withParam
  • Swoole\Coroutine\FastCGI\Proxy->withoutParam
  • Swoole\Coroutine\FastCGI\Proxy->getParams
  • Swoole\Coroutine\FastCGI\Proxy->withParams
  • Swoole\Coroutine\FastCGI\Proxy->withAddedParams
  • Swoole\Coroutine\FastCGI\Proxy->withStaticFileFilter
  • Swoole\Coroutine\FastCGI\Proxy->translateRequest
  • Swoole\Coroutine\FastCGI\Proxy->translateResponse
  • Swoole\Coroutine\FastCGI\Proxy->pass
  • Swoole\Coroutine\FastCGI\Proxy->staticFileFiltrate

HTTP to FastCGI Proxy

This proxy pass functionality is commonly used to communicate between HTTP servers and backend PHP-FPM applications like WordPress. For a full FastCGI Swoole HTTP Server example checkout the WordPress Proxy Pass Example.