The Fiber class

- « Generator::__wakeup

- Fiber::__construct »

- PHP Manual
- Predefined Interfaces and Classes
- The Fiber class

# The Fiber class

(PHP 8 >= 8.1.0)

## Introduction

Fibers represent full-stack, interruptible functions. Fibers may be suspended from anywhere in the call-stack, pausing execution within the fiber until the fiber is resumed at a later time.

## Class synopsis

final class Fiber {
/* Methods */
public __construct(callable `$callback`)
public start(mixed `...$args`): mixed
public resume(mixed `$value` = `null`): mixed
public throw(Throwable `$exception`): mixed
public getReturn(): mixed
public isStarted(): bool
public isSuspended(): bool
public isRunning(): bool
public isTerminated(): bool
public static suspend(mixed `$value` = `null`): mixed
public static getCurrent(): ?Fiber
}

## See Also

Fibers overview

## Table of Contents

- Fiber::__construct — Creates a new Fiber instance
- Fiber::start — Start execution of the fiber
- Fiber::resume — Resumes execution of the fiber with a value
- Fiber::throw — Resumes execution of the fiber with an exception
- Fiber::getReturn — Gets the value returned by the Fiber
- Fiber::isStarted — Determines if the fiber has started
- Fiber::isSuspended — Determines if the fiber is suspended
- Fiber::isRunning — Determines if the fiber is running
- Fiber::isTerminated — Determines if the fiber has terminated
- Fiber::suspend — Suspends execution of the current fiber
- Fiber::getCurrent — Gets the currently executing Fiber instance