libevent is an event-triggered network library, suitable for windows, linux, freebsd and other platforms. It internally uses system calls such as select, poll, epoll, kqueue and other system calls to manage event mechanisms. Let’s learn with the editor how to install the Libevent extension.

1. Introduction to libevent
libevent is an event-triggered network library, suitable for windows, linux, freebsd and other platforms. It uses select, System calls such as poll, epoll, and kqueue manage event mechanisms. Libevent is cross-platform and has extraordinary performance. It is event-driven like nodejs; official website: http://libevent.org/
Latest stable version
https://github.com/downloads/libevent/libevent/libevent -2.0.16-stable.tar.gz
Main modules:
Event processing framework
Event engine module
Buffer management module
Signal processing module
php itself does not support multi-threading, and php cannot implement the concurrency mechanism very well. The pcntl (process control), libevent extension, socket package, and stream system functions provided by Pecl can easily develop high-performance, high-concurrency network applications using PHP.
Simple application example: Pcntl fork n workers. After the master process gets the request, the processing information is sent to the worker program, and the worker sends it back to the client after processing. Master process can set the number of workers, that is, the size of n, according to the amount of concurrency, and monitor the data of workers, and start more processes when there is insufficient. Same as nginx principle.
Attachment: Php network programming framework
http://code.google.com/p/swoole/downloads/list
2. Why should you learn libevent
http server can be said to be a classic application of libevent. You can find the standard writing method of http from libevent. The non-blocking http server is the intertwining of socket processing and http protocol processing.
Learning libevent can help improve your programming skills. In addition to network programming, Libevent's code has many useful design techniques and basic data structures, such as information hiding, function pointers, and polymorphism in C language. Support, linked lists, heaps, etc., all help to improve one's programming skills [1].
Three types of request processing:
connection input fork a new process
connection input pthread_create
connection input throw a Event-based array; main process do nonblocking things;
3. Php libevent extension module installation
Curl –O https://github.com/downloads/libevent/libevent/libevent-2.0.16-stable.tar.gz
Tar –zxvf libevent-2.0.16-stable.tar.gz Cd libevent-2.0.16-stable /usr/local/php/bin/phpize ./configure make make install vi /usr/local/php/etc/php.ini extension_dir=””; extension=libevent.so php –m | grep lib
Installation successful
Recommended learning:php Video tutorial
The above is the detailed content of How to install Libevent extension for PHP. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Chinese version
Chinese version, very easy to use

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.






