Coder Social home page Coder Social logo

event-loop's Introduction

Revolt   

Revolt is a rock-solid event loop for concurrent PHP applications. The usual PHP application spends most of its time waiting for I/O. While PHP is single threaded, cooperative multitasking can be used to allow for concurrency by using the waiting time to do different things.

PHP's traditional synchronous execution flow is easy to understand. Doing one thing at a time. If you query a database, you send the query and wait for a response from the database server. Once you have the response, you can start doing the next thing.

Amp, ReactPHP, and other libraries have offered cooperative multitasking in PHP for a long time. However, their event-driven nature was incompatible to many existing interfaces and required a different thinking model. PHP 8.1 ships with fibers built-in, which offers cooperative multi-threading. Calls can be synchronous without promises or callbacks, while still allowing for non-blocking I/O.

Every application making use of cooperative multitasking needs a single scheduler (also called event loop), which this package provides. Revolt is the result of combining years of experience of Amp's and ReactPHP's event loop implementations. However, it is not a full-blown framework for writing concurrent PHP applications, but only provides what's necessary as a common base. Different (strongly) opinionated libraries can be built on top of it and both Amp and ReactPHP will continue to co-exist.

Installation

It may surprise people to learn that the PHP standard library already has everything we need to write event-driven and non-blocking applications. This package can be installed as a Composer dependency on PHP 8.1 and later.

composer require revolt/event-loop

Applications with many concurrent file descriptors require one of the extensions.

→  View documentation
→  View examples

Versioning

revolt/event-loop follows the semver semantic versioning specification.

License

The MIT License (MIT). Please see LICENSE file for more information.

event-loop's People

Contributors

azjezz avatar bwoebi avatar kelunik avatar nevay avatar nhedger avatar tnsoftbear avatar trowski avatar xjaja avatar

Watchers

 avatar

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.