/react

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

Primary LanguagePHPMIT LicenseMIT

ReactPHP Logo

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

Build Status

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, interaction with processes. Third-party libraries can use these components to create async network clients/servers and more.

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).

Design goals

  • Usable with a bare minimum of PHP extensions, add more extensions to get better performance.
  • Provide a standalone event-loop component that can be re-used by other libraries.
  • Decouple parts so they can be replaced by alternate implementations.

ReactPHP is non-blocking by default. Use workers for blocking I/O.

Core Components

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 and server sockets for ReactPHP. Read the documentation

Protocol Components

Utility Components

Getting started

ReactPHP consists of individual components. This means that instead of installing something like a "ReactPHP framework", you actually pick only the components that you need.

The recommended way to install these components is through Composer. New to Composer?

For example, this may look something like this:

$ composer require react/event-loop react/http

For more details, check out ReactPHP's homepage for quickstart examples and usage details.

Documentation

Superficial documentation can be found in the README files of the individual components. See vendor/react/*/src/README.md.

Community

Check out #reactphp on irc.freenode.net. Also follow @reactphp on twitter.

Tests

To run the test suite, you first need to clone this repo and then install all dependencies through Composer:

$ composer install

To run the test suite, go to the project root and run:

$ php vendor/bin/phpunit

License

MIT, see LICENSE.