Swoole 2.0 release, co-process features support PHP 7

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.