Libevent 是一個用C語言編寫的、輕量級的開源高性能I/O框架,支持多種 I/O 多路複用技術: epoll、 poll、 dev/poll、 select 和 kqueue 等;支持 I/O,定時器和信號等事件;註冊事件優先級。PHP提供了對應的擴展 libevent、 Event 。php
相比 libevent ext, event ext 擁有更好的性能表現和更全面的API,可讓咱們更友好的使用 Libevent。git
php event 擴展 依賴 Libevent 庫,須要先編譯安裝(注意是 Libevent 庫,非 libevent 擴展)。github
git clone --depth=1 https://github.com/nmathewson/Libevent.git cd Libevent ./autogen.sh ./configure --prefix=/usr/local/libevent make && make install
能夠直接使用 pecl
安裝框架
pecl install event downloading event-2.5.3.tgz ... Starting to download event-2.5.3.tgz (140,913 bytes) ..............................done: 140,913 bytes 50 source files, building running: phpize Configuring for: PHP Api Version: 20180731 Zend Module Api No: 20180731 Zend Extension Api No: 320180731 Enable internal debugging in Event [no] : Enable sockets support in Event [yes] : libevent installation prefix [/usr] : /usr/local/libevent ... Build process completed successfully Installing '/usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/event.so' install ok: channel://pecl.php.net/event-2.5.3 Extension event enabled in php.ini
查看安裝結果socket
[root@localhost ~]# php --ri event event Event support => enabled Sockets support => enabled Debug support => disabled Extra functionality support including HTTP, DNS, and RPC => enabled OpenSSL support => enabled Thread safety support => disabled Extension version => 2.5.3 libevent2 headers version => 2.2.0-alpha-dev