reactphp

2025-12-10 0 803

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

ReactPHP is a lowlevel 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

// $ composer require react/http react/socket # install example using Composer
// $ php example.php # run example on command line, requires no additional web server

require __DIR__ . \'/vendor/autoload.php\';

$server = new React\\Http\\HttpServer(function (Psr\\Http\\Message\\ServerRequestInterface $request) {
    return React\\Http\\Message\\Response::plaintext(
        \"Hello World!\\n\"
    );
});

$socket = new React\\Socket\\SocketServer(\'127.0.0.1:8080\');
$server->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 and server sockets for ReactPHP.
    Read the documentation

  • HTTP
    Event-driven, streaming HTTP client and server implementation for ReactPHP.
    Read the documentation

  • DNS
    Async DNS resolver for ReactPHP.
    Read the documentation

Utility Components

  • Cache
    Async caching for ReactPHP.
    Read the documentation

  • ChildProcess
    Library for executing child processes.
    Read the documentation

  • PromiseTimer
    Trivial timeout implementation for ReactPHP\’s Promise lib.
    Read the documentation

  • PromiseStream
    The missing link between Promise-land and Stream-land, built on top of ReactPHP.
    Read the documentation

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

  • Christian Lück
    Pushing the limits with ReactPHP

  • Jeremy Mikola
    Async PHP With React

  • Igor Wiedler
    Event-driven PHP

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

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:

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 during CI runs. If you also do not want to run these,
they can simply be skipped like this:

vendor/bin/phpunit --exclude-group internet

License

MIT, see LICENSE.

下载源码

通过命令行克隆项目:

git clone https://github.com/reactphp/reactphp.git

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

申明:本文由第三方发布,内容仅代表作者观点,与本网站无关。对本文以及其中全部或者部分内容的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。本网发布或转载文章出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,也不代表本网对其真实性负责。

左子网 编程相关 reactphp https://www.zuozi.net/32985.html

anti AD
上一篇: anti AD
常见问题
  • 1、自动:拍下后,点击(下载)链接即可下载;2、手动:拍下后,联系卖家发放即可或者联系官方找开发者发货。
查看详情
  • 1、源码默认交易周期:手动发货商品为1-3天,并且用户付款金额将会进入平台担保直到交易完成或者3-7天即可发放,如遇纠纷无限期延长收款金额直至纠纷解决或者退款!;
查看详情
  • 1、描述:源码描述(含标题)与实际源码不一致的(例:货不对板); 2、演示:有演示站时,与实际源码小于95%一致的(但描述中有”不保证完全一样、有变化的可能性”类似显著声明的除外); 3、发货:不发货可无理由退款; 4、安装:免费提供安装服务的源码但卖家不履行的; 5、收费:价格虚标,额外收取其他费用的(但描述中有显著声明或双方交易前有商定的除外); 6、其他:如质量方面的硬性常规问题BUG等。 注:经核实符合上述任一,均支持退款,但卖家予以积极解决问题则除外。
查看详情
  • 1、左子会对双方交易的过程及交易商品的快照进行永久存档,以确保交易的真实、有效、安全! 2、左子无法对如“永久包更新”、“永久技术支持”等类似交易之后的商家承诺做担保,请买家自行鉴别; 3、在源码同时有网站演示与图片演示,且站演与图演不一致时,默认按图演作为纠纷评判依据(特别声明或有商定除外); 4、在没有”无任何正当退款依据”的前提下,商品写有”一旦售出,概不支持退款”等类似的声明,视为无效声明; 5、在未拍下前,双方在QQ上所商定的交易内容,亦可成为纠纷评判依据(商定与描述冲突时,商定为准); 6、因聊天记录可作为纠纷评判依据,故双方联系时,只与对方在左子上所留的QQ、手机号沟通,以防对方不承认自我承诺。 7、虽然交易产生纠纷的几率很小,但一定要保留如聊天记录、手机短信等这样的重要信息,以防产生纠纷时便于左子介入快速处理。
查看详情

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务