Learning notes of swoole (1)



Continuous update…

I’ve been working for some time, and occasionally I’ve heard about spool. Take a rough look at my PHP little whitefileI think it’s awesome. Because of the high cost of learning, I don’t know much about asynchronous network communication,The documentation is not very friendly to novicesIt’s hard to avoid stumbling on the way to learn swoole, so I want to write some experience

But spoole is a technology that PHP programmers must learn. No, spoole is not a good php programmer

Inadvertently see the new textbook of teacher singwa, it can be said that it is the best course of swoole in the whole network (the link will be attached later), so I want to share my experience with you here.

1. What is spool? What can this guy do?

Swoole is not a framework. Swoole is a high-performance extension of PHP written by Han Tianfeng in C, while swoole framework is a PHP framework based on swoole. In addition, easywoole is also included
PHP’s existing application mode is based on HTTP, which is weak for the situation that needs fast and real-time response, such as online games or push service, generally needs to maintain a TCP connection with users for a long time in order to respond and push information in real time( Personal understanding)
Swoole is the solution to such an application scenario.

2. The foundation of learning swoole

Proficient in PHP, Linux and redis are required

3. Learning ideas

(1) It’s important to understand the difference between TCP, UDP, HTTP, socket and websocket
You can refer to the article here for understandinghttps://blog.csdn.net/sinat_3…
(2) Look at each case of the document once and try to use it once
(3) Combined with the document to see how others write each project
(4) Finally, it is our own actual combat
Ps:fileWe must see more. If you don’t understand the suggestions, you’d better buy this set of courses and read them together.

What you need to know before you learn

(1) Version support:
Spool 1.8.7 or higher is fully compatible with php7
2.0.12PHP5 is no longer supported

(2) The Linux distribution recommended by the system does not support windows. Developers of windows can build linux environment through VM
Sort out the common commands of spool
(a) PHP file name. PHP executor
(b) CTRL + C forced exit program
(c) Telnet port number TCP connection service test
(d) Netcat port number UDP server connection test
(e) Netstat – an | grep port view port, occupied port will not be used
(f) PS – an | grep file name to see the process through the file (you can also see the number of threads)
(g) Kill – 9 PID kill process

5. Install spool

There are two ways to install: 1. Compile and install; 2. PECL
It is recommended to use compilation and installation, which is more conducive to learning

How to check whether the installation is successful?
PHP – m to see if the spool extension has been installed

After installing spoole, we can use it happily^-^

If this article is useful to you, you can praise it or collect it as an encouragement to the author~
PS: the author’s ability is limited. If there is anything wrong, you can boldly put forward it~~~~

Document address portal:https://wiki.swoole.com/wiki/…
Recommend teacher singwa’s video tutorial:https://coding.imooc.com/clas…

Also attached is my website…www.entercode.cnPromote a wave of

Recommended Today

Analysis of super comprehensive MySQL statement locking (Part 1)

A series of articles: Analysis of super comprehensive MySQL statement locking (Part 1) Analysis of super comprehensive MySQL statement locking (Part 2) Analysis of super comprehensive MySQL statement locking (Part 2) Preparation in advance Build a system to store heroes of the Three KingdomsheroTable: CREATE TABLE hero ( number INT, name VARCHAR(100), country varchar(100), PRIMARY […]