Join 4,000+ others and never miss out on new tips, tutorials, and more.
4.x is outdated, please check the latest version 22.x
pecl install openswoole-22.0.0
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
To understand more about this class and its methods you can view the source code on GitHub.
Version: Swoole: 4.5.0+
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.