Skip to content

Installation

Muhammet Şafak edited this page Jun 10, 2026 · 1 revision

Installation

Requirements

  • PHP 8.1 or later. Fibers were added to the language in PHP 8.1, and FiberLoops is built directly on them. There is no extension to install — fibers are part of core PHP.

You can confirm your version with:

php -v

Install with Composer

composer require initphp/fiber-loops

That is the whole dependency footprint: the package requires nothing but PHP itself.

Autoloading

FiberLoops ships a PSR-4 autoloader under the InitPHP\FiberLoops\ namespace. Once installed, pull in Composer's autoloader and you are ready:

require_once 'vendor/autoload.php';

use InitPHP\FiberLoops\Loop;

$loop = new Loop();

The public classes are:

Class Purpose
InitPHP\FiberLoops\Loop The scheduler.
InitPHP\FiberLoops\LoopInterface The contract Loop implements (depend on this for inversion / mocking).
InitPHP\FiberLoops\Exception\LoopException Thrown when the loop is misused (e.g. yielding outside a fiber).

Verify the install

Save this as smoke.php next to your vendor/ directory and run it:

<?php
require_once 'vendor/autoload.php';

use InitPHP\FiberLoops\Loop;

$loop = new Loop();
$loop->defer(function () {
    echo "FiberLoops is working.\n";
});
$loop->run();
php smoke.php
FiberLoops is working.

If you see that line, you are ready for the Quick Start.

Versioning

The package follows Semantic Versioning. The 2.x line requires PHP 8.1+ and exposes the API documented throughout this wiki. See the Changelog for what changed between releases.

Clone this wiki locally