The Swoole 2.0 release is in its official version. The largest update for the 2.0 version is the addition of support for the co-process (Coroutine). The official version has supported both PHP5 and PHP7. Based on the Swoole2.0, PHP developers can write code in a synchronized manner, and the underlying auto-schedule is changed to asynchronous IO. Solves the problem of traditional asynchronous programming nesting callbacks.
The swoole process does not need to modify the code to add additional keywords when compared to languages such as node. JS (es6+), Python, and so on using Yield/generator and async/await implementations.
Compared with the goroutine of the Go language, the Swoole is built-in, the application layer code does not need to add the Go keyword to start the process, it only needs to use the packaged co-client, the use is simpler. In addition, the IO component of the swoole process has a timeout mechanism built into the underlying, which does not require the use of complex select/chan/timer to implement client timeouts.
At present, the Swoole bottom built-in client components include: UdpClient, TcpClient, HttpClient, Redisclient, Mysqlclient, which basically covers several communication protocols commonly used by developers. The coprocessor component can only be used in the server's OnConnect, ONrequest, OnReceive, OnMessage callback functions.
Examples of Use:
UDP client:
UDP client:
MySQL client:
Redis Client:
HTTP client:
Swoole 2.0 release, co-process features support PHP 7