True coroutines for PHP>=8.1 without worrying about event loops and callbacks.

Last update: Jun 16, 2022

Moebius

Pure coroutines for PHP 8.1. To promises and callbacks needed. Just pure parallel PHP code inside coroutines.

Moebius Band: A loop with only one surface

Möbuus Loop


What is this?

Completely transparent coroutines thanks to PHP 8.1 Fibers. No complex nested callbacks or promise trees. Just plain old-school PHP code running asynchronously, like in GoLang.

The easiest way to bring your codebase up to speed with high performance event based concurrency. It's like Swoole, but without the extension.

Asynchronous IO

Moebius will transparently switch between your coroutines whenever you are reading or writing to disk - so you don't need to worry about special async versions of common commands like file_get_contents and such.

Like GoLang, not like JavaScript

The main thing that makes PHP a very productive language, is that you can do much with very simple, single-threaded code.

With Moebius, you don't have to change your coding style.

Old-school javascript

    // Do something 10 times, once every second
    let counter = 0;
    let i = setInterval(() => {
        console.log("Every second");
        if (counter === 10) {
            clearInterval(i);
        }
    }, 1000);

"Cool" javascript

Ecmascript has introduced the async/await keywords, but you can't use them wherever you want. Not good.

    // need to make a sleep() function
    function sleep(time) {
        return new Promise((resolve) => {
            setTimeout(resolve, time * 1000);
        }
    }

    async function count() {
        for (let i = 0; i < 10; i++) {
            console.log("Every second");
            await sleep(1);
        }
    }

    // You CAN'T use the `await` function everywhere

Very cool PHP 8.1

Just call your function with go() (globally asynchronously), or with await(go()) (locally asynchronously).

    use M\{go, sleep};

    // Do something 10 times, once every second
    go(function() {
        for ($i = 0; $i < 10; $i++) {
            echo "Every second\n";
            sleep(1);
        }
    });

GitHub

https://github.com/frodeborli/moebius
You might also like...

This library is an implementation of League\Event for Slim Framework

Slim Event Dispatcher This library is an implementation of League\Event for Slim Framework. This works with the latest version of Slim (V3). Installat

Apr 7, 2022

Notify instructors about unconfirmed event registrations.

Notify instructors about unconfirmed event registrations.

SAC Event Registration Reminder Folgende Idee: Es wird ein Reminder-Tool benötigt, welches Tourenleitende und Bergführer/innen per E-Mail daran erinne

Apr 25, 2022

A Laravel artisan based package to create the AWS (SES + SNS) infrastructure to receive email event notifications with Http/Https endpoint.

A Laravel artisan based package to create the AWS (SES + SNS) infrastructure to receive email event notifications with Http/Https endpoint.

Laravel SES Tracking Setup the AWS infrastructure to handle email events using SES/SNS and http/s endpoints with a single Laravel artisan command. Thi

Apr 26, 2022

Allows installing Drupal extensions event if not compatible with installed drupal/core package

mglaman/composer-drupal-lenient Lenient with it, Drupal 10 with it. Why? The Drupal community introduced a lenient Composer facade that modified the d

May 24, 2022

A Laravel Wrapper for the Binance API. Now easily connect and consume the Binance Public & Private API in your Laravel apps without any hassle.

A Laravel Wrapper for the Binance API. Now easily connect and consume the Binance Public & Private API in your Laravel apps without any hassle.

This package provides a Laravel Wrapper for the Binance API and allows you to easily communicate with it. Important Note This package is in early deve

Jun 19, 2022

Use Ray in any PHP script without requiring it in your projects.

Global Ray Use Ray in any PHP script without requiring it in your projects. Require this package globally with Composer: composer global require cuyz/

Jun 5, 2022

Simple game server with php without socket programming. Uses the Api request post(json).

QMA server Simple game server with php without socket programming. Uses the Api request post(json). What does this code do? Register the user as a gue

Sep 4, 2021

Run Telegram PHP Bot on Windows Localhost without Host or VPN.

Run Telegram PHP Bot on Windows Localhost without Host or VPN.

May 30, 2022

Bank API written in PHP 7.4 without framework

Bank API written in PHP 7.4 without framework

Mar 25, 2022
Comments
  • 1. [Question] Examples showing performance benefits

    Hello, do you have any examples which shows that blocking functions are really paused and executed when result is available? I am talking about something like https://github.com/frodeborli/moebius/blob/master/examples/async-tcp/async-tcp.php but when executing for example 20 requests. I have tried to implement such test but I cannot get any results with execution time better than synchronous execution

    Have a good day! :)

    Reviewed by rutek at 2022-05-19 09:02
λ Run PHP Coroutines & Fibers as-a-Service on the AWS Lambda.
λ Run PHP Coroutines & Fibers as-a-Service on the AWS Lambda.

λ Swoole Runtime for AWS Lambda Run PHP Coroutines & Fibers as-a-Service on the AWS Lambda. Getting started Create your Lambda function index.php <?ph

Feb 19, 2022
Class PHP Api อั่งเปา True Wallet

Description: API อั่งเปา True Wallet (Rework) Features: ตรวจสอบอั่งเปา ใช้อั่งเปา แสดงผลออกมาเป็น Json Example: <?php use M4h45amu7x\Voucher; require

Jun 19, 2022
An open source Minecraft server (true-og.net)

true-og An open source Minecraft server (true-og.net) Website forked from aviel900 https://www.spigotmc.org/resources/minecraft-one-page-template.5973

Apr 9, 2022
JSONFinder - a library that can find json values in a mixed text or html documents, can filter and search the json tree, and converts php objects to json without 'ext-json' extension.

JSONFinder - a library that can find json values in a mixed text or html documents, can filter and search the json tree, and converts php objects to json without 'ext-json' extension.

Apr 15, 2022
Implement event systems, signal slots, intercepting filters, and observers.

zend-eventmanager Repository abandoned 2019-12-31 This repository has moved to laminas/laminas-eventmanager. zend-eventmanager is designed for the fol

Jun 19, 2022
Quickly and easily preview and test your Magento 2 order confirmation page, without hacks or spending time placing new order each time
Quickly and easily preview and test your Magento 2 order confirmation page, without hacks or spending time placing new order each time

Preview Order Confirmation Page for Magento 2 For Magento 2.0.x, 2.1.x, 2.2.x and 2.3.x Styling and testing Magento's order confirmation page can be a

May 19, 2022
It allows frontend developer to send ajax requests and return a custom information from the server without a php developer help

[Magento 1 Extension] It allows frontend developer to send ajax requests and return a custom information from the server without a php developer help (without any php code).

Apr 1, 2022
An Infection + Last Man Standing Event plugin written for OwnagePE

KitPvPEvent An Infection + Last Man Standing Event plugin written for OwnagePE This plugin was a speedcode. I kinda woke up really late on the day I w

May 26, 2022
Psalm plugin for patchlevel/event-sourcing

event-sourcing-psalm-plugin psalm plugin for event-sourcing library. installation composer require --dev patchlevel/event-sourcing-psalm-plugin confi

Dec 30, 2021