reactphp /reactphp

Event-driven, non-blocking I/O with PHP.

★ 9,085⑂ 707👁 356⑃ 264● 213▤ 23
PHPMITCreated 2012-05-10reactphp.org
下载:v1.4.0reactphp-1.4.0 ↓1.4.02023-07-11
-1
日增长
9,085
stars
707
forks
356
watchers
264
prs
213
issues
23
releases

README

Event-driven, non-blocking I/O with PHP.





    




ReactPHP is a low-level library for event-driven programming in PHP. At its core
is an event loop, on top of which it provides low-level utilities, such as:
Streams abstraction, async DNS resolver, network client/server, HTTP
client/server and interaction with processes. Third-party libraries can use these
components to create async network clients/servers and more.

php
listen($socket);

echo "Server running at http://127.0.0.1:8080" . PHP_EOL;


This simple web server written in ReactPHP responds with "Hello World!" for every request.

ReactPHP is production ready and battle-tested with millions of installations
from all kinds of projects around the world. Its event-driven architecture makes
it a perfect fit for efficient network servers and clients handling hundreds or
thousands of concurrent connections, long-running applications and many other
forms of cooperative multitasking with non-blocking I/O operations. What makes
ReactPHP special is its vivid ecosystem with hundreds of third-party libraries
allowing you to integrate with many existing systems, such as common network
services, database systems and other third-party APIs.

 Production ready and battle-tested.
 Rock-solid with stable long-term support (LTS) releases.
 Requires no extensions and runs on any platform - no excuses!
 Takes advantage of optional extensions to get better performance when available.
 Highly recommends latest version of PHP 7+ for best performance and support.
 Supports legacy PHP 5.3+ and HHVM for maximum compatibility.
 Well designed and reusable components.
 Decoupled parts so they can be replaced by alternate implementations.
 Carefully tested (unit & functional).
 Promotes standard PSRs where possible for maximum interoperability.
 Aims to be technology neutral, so you can use your preferred application stack.
 Small core team of professionals supported by large network of outside contributors.

ReactPHP is non-blocking by default. Use workers for blocking I/O.
The event loop is based on the reactor pattern (hence the name) and strongly
inspired by libraries such as EventMachine (Ruby), Twisted (Python) and
Node.js (V8).

 This repository you're currently looking at is mostly used as a meta
  repository to discuss and plan all things @ReactPHP. See the individual
  components linked below for more details about each component, its
  documentation and source code.

 Core Components

 EventLoop
  ReactPHP's core reactor event-loop.
  Read the documentation

 Stream
  Event-driven readable and writable streams for non-blocking I/O in ReactPHP.
  Read the documentation

 Promise
  Promises/A implementation for PHP.
  Read the documentation

 Async
  Async utilities and fibers for ReactPHP.
  Read the documentation

 Network Components

 Socket
  Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP.
  Read the documentation

 Datagram
  Event-driven UDP client a

Discussions

Latest release

v1.4.0 v1.4.0 2023-07-11
A major new feature release, see release announcement.

   Feature: Add support for new Promise v3 release.
    (464 and 524 by @clue)

   Feature: Support PHP 8.2 release.
    (491 by @Nielsvanpach)

   Improve test suite, update dependencies and report failed assertions.
    (462 and 501 by @clue and 466 and 492 by @SimonFrings)

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON