

Event-driven, non-blocking I/O with PHP - ReactPHP
source link: https://reactphp.org/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

ReactPHP: Event-driven, non-blocking I/O with PHP
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.
$loop = React\EventLoop\Factory::create(); $server = new React\Http\Server($loop, function (Psr\Http\Message\ServerRequestInterface $request) { return new React\Http\Message\Response( 200, array( 'Content-Type' => 'text/plain' ), "Hello World!\n" ); }); $socket = new React\Socket\Server(8080, $loop); $server->listen($socket); echo "Server running at http://127.0.0.1:8080\n"; $loop->run();
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.
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).
- 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.
</div
Recommend
-
142
What Is Tick? Tick is one loop iteration where every callback in the queues has been executed synchronously a...
-
150
README.md ...
-
25
README.md
-
10
Non-Blocking Parallelism for Services in Go Dec 6, 2020 10 minute read Go has plenty of useful builtin functionality for safe, concurrent and parallel code. However neat those features may be, the...
-
3
Failure Detectors, and Non-Blocking Atomic Commit Non-blocking atomic commit is harder than uniform consensus. Why would that be? Many of the most interesting results in distributed systems have come from looking at problem...
-
4
MoarTLS: Non-Secure Download Blocking With little fanfare, an important security change has arrived on the web. Now, all major browsers (except Safari) block non-secure downloads from a secure page. Browser Ve...
-
13
a reactive (or non-blocking, or asynchronous) JSON parser « Michel KrämerActson: a reactive (or non-blocking, or asynchronous) JSON parserToday I’m happy to announce the very first version of Actson, a reactive JSON parser (some...
-
5
V2EX › 问与答 关于 Non-Blocking 的终极一问 ojh · 1...
-
10
Sponsor: Do you build complex software systems? See how NServiceBus makes it easier to design, build, and manage software systems that use message queues to achieve loose coupling.
-
10
Getting started with asynchronous PHP using ReactPHP As web developers, we’re all familiar with the request-response model. It usually goes something like this: A user accesses a page using their...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK