ReactPHP

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

  • Owner: reactphp/reactphp
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

ReactPHP是PHP中用于事件驱动编程的低级库。其核心是一个事件循环,在其上方提供低级实用程序,例如:流抽象,异步DNS解析器,网络客户端/服务器,HTTP客户端/服务器以及与进程的交互。第三方库可以使用这些组件来创建异步网络客户端/服务器等。

ReactPHP已经准备好生产并经过全面的数百万次安装测试。其事件驱动架构使其非常适合高效的网络服务器和客户端处理数百或数千个并发连接,长时间运行的应用程序以及具有非阻塞I/O操作的许多其他形式的协作式多任务处理。 ReactPHP的特殊之处在于其生动的生态系统,数百个第三方库允许您与许多现有系统集成,例如通用网络服务,数据库系统和其他第三方API。

特性

  • 生产就绪并经过实战考验。
  • 坚如磐石,稳定的长期支持(LTS)发布。
  • 不需要任何扩展并可在任何平台上运行 - 没有任何借口!
  • 利用可选扩展来获得更好的性能。
  • strong烈推荐最新版本的PHP 7+以获得最佳性能和支持。
  • 支持传统的PHP 5.3+和HHVM以实现最大兼容性。
  • 精心设计和可重复使用的组件。
  • 解耦部分,以便可以通过其他实现替换它们。
  • 经过仔细测试(单位和功能)。
  • 尽可能促进标准PSR以实现最大的互操作性。
  • 旨在保持技术中立,因此您可以使用首选的应用程序堆栈。
  • 由大型外部贡献者网络支持的小型核心专业团队。

默认情况下,ReactPHP是非阻塞的。使用worker来阻止I/O。 事件循环基于reactor模式(因此得名),并受到诸如EventMachine(Ruby),Twisted(Python)和Node.js(V8)等库的strong烈启发。

您当前正在查看的此存储库主要用作元库,用于讨论和规划@ReactPHP的所有内容。有关每个组件,其文档和源代码的更多详细信息,请参阅下面链接的各个组件。

核心组件

  • 事件循环 ReactPHP的核心反应器事件循环。 阅读文档
  • ReactPHP中用于非阻塞I/O的事件驱动的可读可写流。 阅读文档
  • Promise PHP的承诺/实现。 阅读文档

网络组件

  • 插槽 异步、流式纯文本TCP/IP以及ReactPHP的安全TLS套接字服务器和客户端连接。 阅读文档
  • 数据报 ReactPHP的事件驱动UDP客户端和服务器套接字。 阅读文档

协议组件

  • HTTP 用于ReactPHP的事件驱动的流式纯文本HTTP和安全HTTPS服务器。 阅读文档
  • HTTPClient ReactPHP的事件驱动的流式HTTP客户端。 阅读文档
  • DNS ReactPHP的异步DNS解析器。 阅读文档

实用程序组件

  • 缓存 ReactPHP的异步缓存。 阅读文档
  • 子进程 用于执行子进程的库。 阅读文档
  • PromiseTimer ReactPHP的Promise库的一般超时实现。 阅读文档
  • PromiseStream Promise-land和Stream-land之间的缺失链接建立在ReactPHP之上。 阅读文档

开始

ReactPHP由各个组件组成。 这意味着您实际上只选择了所需的组件,而不是像“ReactPHP框架”那样安装。

安装这些组件的推荐方法是通过Composer。 Composer的新手?

例如,这可能看起来像这样:

$ composer require react/event-loop react/http
 

有关更多详情,请参阅 ReactPHP的主页

测试

要运行测试套件,首先需要克隆这个repo,然后安装全部依赖通过Composer

$composer install
 

要运行测试套件,请转到项目根目录并运行:

$ php vendor/bin/phpunit
 

许可证

MIT,请参阅LICENSE。

Main metrics

Overview
Name With Ownerreactphp/reactphp
Primary LanguagePHP
Program languagePHP (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2012-05-10 18:00:00
Pushed At2024-11-25 17:18:22
Last Commit At
Release Count23
Last Release Namev1.4.0 (Posted on 2023-07-11 18:09:22)
First Release Namev0.1.0 (Posted on )
用户参与
Stargazers Count9k
Watchers Count364
Fork Count728
Commits Count1k
Has Issues Enabled
Issues Count213
Issue Open Count0
Pull Requests Count178
Pull Requests Open Count0
Pull Requests Close Count85
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

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.

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

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

Built with ReactPHP

  • Thruway
    PHP Client and Router Library for Autobahn and WAMP (Web Application Messaging
    Protocol) for Real-Time Application Messaging
    voryx/Thruway

  • PPM - PHP Process Manager
    PPM is a process manager, supercharger and load balancer for modern PHP
    applications.
    php-pm/php-pm

  • php-ar-drone
    ? Port of node-ar-drone which allows user to control a Parrot AR Drone over
    PHP
    jolicode/php-ar-drone

  • Ratchet
    Asynchronous WebSocket server
    ratchetphp/Ratchet

  • Predis\Async
    Asynchronous PHP client library for Redis built on top of ReactPHP
    nrk/predis-async

  • clue/redis-server
    A Redis server implementation in pure PHP
    clue/redis-server

And many more on our wiki page »

Articles

  • Sergey Zhuk
    A series of articles covering ReactPHP: from the basics to the real
    application examples.
    sergeyzhuk.me

  • Cees-Jan Kiewiet
    Blog series about several ReactPHP components and how they work.
    blog.wyrihaximus.net

  • Loïc Faugeron
    Super Speed Symfony - ReactPHP.
    gnugat.github.io

  • Marc J. Schmidt
    Bring High Performance Into Your PHP App (with ReactPHP).
    marcjschmidt.de

  • Marc Morera
    When ReactPHP meet Symfony
    medium.com/@apisearch

Talks

Getting started

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

This project follows SemVer for all its stable components.
The recommended way to install these components is through Composer.
New to Composer?

For example, this may look something like this:

# recommended install: pick required components
$ composer require react/event-loop react/http

As an alternative, we also provide a meta package that will install all stable
components at once. Installing this is only recommended for quick prototyping,
as the list of stable components may change over time. This meta package can be
installed like this:

# quick protoyping only: install all stable components
$ composer require react/react:^1.0

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

See also the combined changelog for all ReactPHP components
for details about version upgrades.

Support

Do you have a question and need help with ReactPHP? Don't worry, we're here to help!

As a first step, check the elaborate documentation that comes with each
component (see links to individual documentation for each component above).
If you find your question is not answered within the documentation, there's a
fair chance that it may be relevant to more people. Please do not hesitate to
file your question as an issue in the relevant component so others can also
participate.

You can also check out our official Gitter chat room.
Most of the people involved in this project are available in this chat room, so many
questions get answered in a few minutes to some hours. We also use this chat room
to announce all new releases and ongoing development efforts, so consider
staying in this chat room for a little longer.

Also follow @reactphp on Twitter for updates.
We use this mostly for noteworthy, bigger updates and to keep the community
updated about ongoing development efforts. You can always use the #reactphp
hashtag if you have anything to share!

We're a very open project and we prefer public communication whenever possible,
so that more people can participate and help getting the best solutions available.
At the same time, we realize that some things are better addressed in private.
Whether you just want to say thank you, want to report a security issue or
want to help sponsor a certain feature development, you can reach out to the
core team in private by sending an email to support@reactphp.org. Please keep in
mind that we're a small team of volunteers and do our best to support anybody
reaching out.

Do you want to support ReactPHP? Awesome! Let's start with letting the the world
know why you think ReactPHP is awesome and try to help others getting on board!
Send a tweet, write a blog post, give a talk at your local user group or
conference or even write a book. There are many ways you can help. You can
always reach out to us in private and help others in our support channels.
Thank you!

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

The test suite also contains a number of functional integration tests that rely
on a stable internet connection. Due to the vast number of integration tests,
these are skipped by default on Travis CI. If you also do not want to run these,
they can simply be skipped like this:

$ php vendor/bin/phpunit --exclude-group internet

License

MIT, see LICENSE.