Download the PHP package moebius/coroutine without Composer

On this page you can find all versions of the php package moebius/coroutine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package coroutine

moebius/coroutine

True "green threads" (coroutines) for PHP 8.1. No plugins needed. Coroutines are like multitasking, but without many of the subtle problems that come from threads.

Compatability

Moebius runs other event loops cooperatively; if you are using React, Moebius will run the React Event loop, if you are using Amp, Moebius will run the Amp event loop.

TIP! To make compatible event-loop based applications, you can implement against the moebius/loop implementation yourself.

Essentials

A coroutine is a function which runs in parallel with other code in your application. You can work with coroutines the same way you work with promises in frameworks like React or Amp. In fact, you can use most promise based libraries with Moebius.

Conceals the promises

The main purpose of moebius is to conceal the existence of promises; you should not have to think about coroutines being a part of your application. The only time you need to think about coroutines, is when you need to do multiple things in parallell.

Moebius allows your application to handle multiple requests in parallel, but your program flow should not have to worry about that.

A Coroutine is a Promise

When you create a coroutine, you get a promise about a future result. That future result can be accessed via the then() method, just like any other promise object you're used to.

A Promise is a Coroutine

<?php require "vendor/autoload.php";

use Moebius\Coroutine as Co;

foreach (glob(__DIR__.'/*') as $path) {
    if (is_file($path)) {
        Co::go('print_file', $path);                    // <-- Co::go() launches a function as a "green thread"
    }
}

/**
 * Watch function which will monitor files for added lines
 */
function print_file(string $filename) {
    $fp = Co::unblock(fopen($filename, "r"));           // <-- Co::unblock() makes the stream cooperation friendly

    while (!feof($fp)) {
        echo fgets($line, 4096);
    }
}

<?php
use function M\{go, sleep};
go(function() {
    while (true) {
        echo date('c')."\n";
        sleep(5);
    }
});
```

All versions of coroutine with dependencies

PHP Build Version
Package Version
Requires moebius/promise Version >=1.0.100
moebius/loop Version >=1.0.100
moebius/common Version >=1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package moebius/coroutine contains the following files

Loading the files please wait ....