Home  >  Article  >  PHP Framework  >  PHP support does not support swoole

PHP support does not support swoole

(*-*)浩
(*-*)浩Original
2019-12-12 11:09:362156browse

PHP support does not support swoole

Swoole’s features:

Network communication framework, asynchronous, multi-threading. These features are exactly the imperfect functions of PHP (although the official provides many basic functions to realize these functions, but there is a lack of Chinese documentation, and few people use PHP to implement these functions). Ordinary PHP does not have the basic understanding of these features. You know, so if you use swoole rashly, you will inevitably encounter some common sense problems that cannot be found in the swoole official website. (Recommended learning: swoole video tutorial)

Skills that must be mastered to use swoole

Multi-threaded programming

Inter-process Communication

Cognition of network protocol TCP/UDP

Basic skills of PHP

Experience of learning swoole

In A long time ago, I was a programmer who only knew PHP. Then I needed to use httpsqs by chance. After using it for a while, I found that I had some unique needs, so I started looking at the source code. This is really hard to see, and it is shocking at first glance. httpsqs is just a simple packaging, and inside is a Tokyo Cabinet database. In my impression, the packaged code is only more than a hundred lines.

The main idea is to use libevent in C language to make an http server to receive requests to read and write tokyo cabinet database. At that time, there were indeed many programs based on this idea. Later, I suddenly thought that since C language can use the libevent function, PHP can definitely use libevent to monitor the network, read and write the database for queue service after receiving the request.

After checking the official PHP documentation, I found that PHP does provide a complete system of functions to complete these functions, and even a full set of multi-threaded functions are provided. However, there are too few Chinese documents, and mature ones are rarely found online. code.

Under forced circumstances, I learned the basic principles of Linux-C multi-thread development, common methods of inter-process communication, and also used it to make some simple demos.

The only feeling is that writing a simple function is really complicated to design. Just when I was about to give up, swoole appeared.

The functions provided by swoole are exactly the functions missing in php, which is simply great. As a network communication framework, swoole only requires a few simple lines of settings to set up a server. From now on, we will continue to improve the business code.

I learned in the libevent exchange group that swoole's design is not the best framework design in c\c, but its highlight is that the basic functions are encapsulated in C, and the business functions are left to the best in the world. Written in the language PHP. Since then, Swoole's journey of filling holes has begun.

Summary

swoole is not a simple PHP framework. Just like the first sentence of swoole's official homepage "Redefine PHP", do not use it Use the old PHP thinking to write swoole code! swoole reactivates PHP, and php makes swoole!

The above is the detailed content of PHP support does not support swoole. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to call swoole in phpNext article:How to call swoole in php