Giter Club home page Giter Club logo

website's Introduction

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

Network 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.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 [email protected]. 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.

website's People

Contributors

cboden avatar clue avatar dependabot[bot] avatar igorw avatar jsor avatar nhedger avatar seregazhuk avatar tabuna avatar umpirsky avatar wyrihaximus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

website's Issues

Website build running into rate limitings

Mostly after releasing a new version for one of our ReactPHP components, we need to trigger the website build in order to show each new released version there. When running the GitHub actions deployment workflow for this, we recently tend to run into rate limitings:

Temporary error, will retry in 60s: API rate limit exceeded for installation ID 14316185.
PHP Fatal error:  Uncaught Github\Exception\RuntimeException: API rate limit exceeded for installation ID 14316185. in /home/runner/work/website/website/vendor/knplabs/github-api/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php:126
Stack trace:
#0 /home/runner/work/website/website/vendor/php-http/httplug/src/Promise/HttpFulfilledPromise.php(34): Github\HttpClient\Plugin\GithubExceptionThrower->Github\HttpClient\Plugin\{closure}(Object(GuzzleHttp\Psr7\Response))
#1 /home/runner/work/website/website/vendor/knplabs/github-api/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php(127): Http\Client\Promise\HttpFulfilledPromise->then(Object(Closure))
#2 /home/runner/work/website/website/vendor/php-http/client-common/src/Plugin/VersionBridgePlugin.php(19): Github\HttpClient\Plugin\GithubExceptionThrower->doHandleRequest(Object(GuzzleHttp\Psr7\Request), Object(Closure), Object(Closure))
#3 /home/runner/work/website/website/vendor/php-http/client-common/src/PluginClient.php(161): Github\HttpClient\Plugin\GithubExceptionThrower in /home/runner/work/website/website/vendor/knplabs/github-api/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php on line 126
Error: Process completed with exit code 255.

It sometimes works when retrying to run the failed workflow, but with each release it seems to get harder for this deployment process to be successful. I didn't investigate this in detail yet, so I'm happy about your input on this.

Documentation for triggering website rebuild (deploy on reactphp.org)

The README contains information on how to build this project to a set of static files. Once these files have been generated, you can either view them locally or deploy them to a website.

This project uses Travis to deploy these resulting files to https://github.com/reactphp/reactphp.github.io. That other project is set up to use GitHub pages to simply publish everything that is stored within to the web under reactphp.github.io which uses the alias reactphp.org.

This deployment is configured as part of this project via the .travis.yml file. This means that whenever Travis detects changes on the master branch of this repository, a new rebuild and deployment will be triggered instantly.

However, this project builds the website from a number of external repositories, in particular the READMEs of our components. This means that most of the changes that are supposed to be published are actually not part of this project at all.

For this reason, this project uses Travis' cron jobs to trigger a website rebuild and deployment every day (https://travis-ci.org/reactphp/website/settings). This means that any changes will be picked up automatically once every day and the website will automatically stay up to date.

However, there are number of occasions where this "rebuild once per day" may not be sufficient. In particular, if a new component version is tagged and released, it may take up to 24h for this to show up on our homepage. This means that if the release is announced, the website may still show an outdated version.

For this reason, this ticket adds required documentation on how to manually trigger a new website rebuild and deployment to instantly update the website. Go to https://travis-ci.org/reactphp/website and click on "Trigger build" in the upper right corner (hamburger menu). This should open a "Trigger a custom build (Beta Feature)" dialog that can simply be confirmed with the preset values. Obviously, this requires valid authentication. This should lead you to a new build which should take a minute or two to complete and publish online πŸŽ‰

Opening this ticket for the reference only (https://github.com/reactphp/react/wiki/ReleaseProcess#release-checklist), so I'll assume this can be closed right away.

Add Atom feed for new releases

We should add some Atom feed links to the releases page. These feeds are already created by GitHub, so we don't really need to have them as part of our website and it's merely a matter of setting up some links.

<link href="https://github.com/reactphp/socket/releases.atom" type="application/atom+xml" rel="alternate" title="Socket releases" />

Also related to #30 at which point we may want to dump the same listing into an Atom feed.

Website via HTTPS

We received a tweet yesterday about the inability to reach the website via HTTPS: https://twitter.com/_le_futuriste/status/898835476827828224

We can handle this in a few different ways:

  • Do nothing and wait for @github to support it
  • Set up an AWS CloudFront distribution
  • Set up CloudFlare

The latter is by far my favourite but I don't mind setting up the CloudFront distribution and paying for it πŸ˜„ .

Twig Extension undefined index notice

The ReactPHP website displays a PHP notice with its stack trace in the activity box on the lower right (see attached screenshot).

This happens because the $participation array does not contain the index all. Might have sth. to do with connectivity issues to Travis, or maybe they changed something on their side?

auswahl_029

Link to reactphp/react instead of reactphp organization

The homepage currently links to https://github.com/reactphp as the main entry point for GitHub links. Now that reactphp/reactphp#384 is in, I think it makes more sense to link to https://github.com/reactphp/react instead. After discussing this with a number of people I agree that linking to the organization level may leave people wondering where to look next. Note that we may have to address reactphp/reactphp#348 first.

Any input is welcome πŸ‘

Website build does not include latest Datagram v1.9.0

For some reason, the website build process detects reactphp/datagram v1.8.0 as the latest version and and does not include the latest release: https://github.com/reactphp/datagram/releases/tag/v1.9.0

I've manually executed the build again, but the problem persists. See also last build output: https://github.com/reactphp/website/actions/runs/4151388784/jobs/7181669476#step:8:120

Only stumbled upon this today and haven't analyzed this in-depth yet, any help would be appreciated.

Changelog does not link to issues and authors

The changelog for each component does not currently link to issues (#NUMBER) or author names (@NAME). Compare for example https://reactphp.org/stream/changelog.html with https://github.com/reactphp/stream/releases.

I think it makes sense to implement this feature so that links are added automatically for consistency reasons. This only applies to the changelog and not the other markdown files, so I suppose it's relatively safe to apply some simple regular expressions here.

Any input is welcome πŸ‘

Outdated example in the home page

The example in the home page is outdated. By using it as is we get a fatal error.

index.php:

require 'vendor/autoload.php';

$app = function ($request, $response) {
    $response->writeHead(200, array('Content-Type' => 'text/plain'));
    $response->end("Hello World\n");
};

$loop = React\EventLoop\Factory::create();
$socket = new React\Socket\Server($loop);
$http = new React\Http\Server($socket, $loop);

$http->on('request', $app);
echo "Server running at http://127.0.0.1:1337\n";

$socket->listen(1337);
$loop->run();

composer.json:

{
    "require": {
        "react/event-loop": "^0.4.3",
        "react/socket": "^0.8",
        "react/http": "^0.7.1"
    }
}

error message:

PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function React\Socket\Server::__construct(), 1 passed in reactphp\index.php on line 11 and at least 2 expected in reactphp\vendor\react\socket\src\Server.php:12
Stack trace:
#0 reactphp\index.php(11): React\Socket\Server->__construct(Object(React\EventLoop\StreamSelectLoop))
#1 {main}
  thrown in reactphp\vendor\react\socket\src\Server.php on line 12

Fatal error: Uncaught ArgumentCountError: Too few arguments to function React\Socket\Server::__construct(), 1 passed in reactphp\index.php on line 11 and at least 2 expected in reactphp\vendor\react\socket\src\Server.php:12
Stack trace:
#0 reactphp\index.php(11): React\Socket\Server->__construct(Object(React\EventLoop\StreamSelectLoop))
#1 {main}
  thrown in reactphp\vendor\react\socket\src\Server.php on line 12

Add combined changelog for all components

Currently, the website shows a changelog for each individual component, for example https://reactphp.org/socket/changelog.html. I think we agree that this makes perfect sense, for example for users wishing to upgrade a single component.

Additionally, we should also add a changelog for all components listing all the changes on one page. This allows users to have a quick glimpse at "what changed since last time I've upgraded?", "what changed in the last 6 months?", "how active is this project?".

We can use GitHub's releases API to get a list of all releases for a single repository and use GitHub's organization API to iterate over all repositories within the @reactphp organization. An example output of this could look something like this: https://gist.github.com/clue/f2be153e5ac73773dc75df2131eacd04 (created via https://gist.github.com/clue/431368a31405b76ab5cc643c7b00ad37)

For now, dumping this into a single HTML file on the website should suffice, in the future we may want to apply some pagination logic (possibly by year or number of entries).

Use HTTPS via GitHub

GitHub started supporting HTTPS for custom domains a few days ago. We currently rely on Cloudflare (#18) as an intermediary to offer HTTPS. While Cloudflare has worked really well, we may as well switch back now that GitHub has native HTTPS support, so that we rely on one less external provider.

Changing this is simply a matter of updating the DNS A records as per this article: https://help.github.com/articles/setting-up-an-apex-domain/#configuring-a-records-with-your-dns-provider

Update website with project pages and documentation

One of the criticisms made against reactphp is the lack of documentation. Currently the website shows a small example on making a webserver while there is a lot more to the project. My suggestion is to add project pages for each component on the website and add simple getting started examples. This to make the learning curve easier.

Trigger website rebuild via webhook when new release is tagged

The README contains information on how to build this project to a set of static files. Once these files have been generated, you can either view them locally or deploy them to a website.

This project uses Travis to deploy these resulting files to https://github.com/reactphp/reactphp.github.io. That other project is set up to use GitHub pages to simply publish everything that is stored within to the web under reactphp.github.io which uses the alias reactphp.org.

This deployment is configured as part of this project via the .travis.yml file. This means that whenever Travis detects changes on the master branch of this repository, a new rebuild and deployment will be triggered instantly.

However, this project builds the website from a number of external repositories, in particular the READMEs of our components. This means that most of the changes that are supposed to be published are actually not part of this project at all.

For this reason, this project uses Travis' cron jobs to trigger a website rebuild and deployment every day (https://travis-ci.org/reactphp/website/settings). This means that any changes will be picked up automatically once every day and the website will automatically stay up to date.

However, there are number of occasions where this "rebuild once per day" may not be sufficient. In particular, if a new component version is tagged and released, it may take up to 24h for this to show up on our homepage. This means that if the release is announced, the website may still show an outdated version.
– See #24

This release process currently needs to be triggered manually as per https://github.com/reactphp/react/wiki/ReleaseProcess#release-checklist or it may take up to 24h before release updates show up automatically.

To improve this, we should automatically trigger a website rebuild whenever a new component release is tagged. The easiest way would be to set up a webhook for each component to trigger a simple script which will then trigger the Travis CI API (https://docs.travis-ci.com/user/triggering-builds/). In this case, we can probably also remove the cron job.

Implementation wise this isn't too hard and should really only be a simple PHP script with 10 lines or so. Question remains on where to best store this script (like my personal website hosting?) and/or whether there are any better alternatives? Any input is appreciated!

Menu behaviour on Safari

The navigation menu is acting weird on Safari:

Screen Shot 2019-11-06 at 11 54 45 AM

  • Touching the menu produces the above screenshot
  • Upon scrolling down it appears
  • Once open the X to close only works if the user has scrolled back to the top of the page
  • Closing the menu produces the same screenshot posted above

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.