Download the PHP package reinfyteam/libasync without Composer
On this page you can find all versions of the php package reinfyteam/libasync. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download reinfyteam/libasync
More information about reinfyteam/libasync
Files in reinfyteam/libasync
Package libasync
Short Description Asynchronous runtime and coroutine tools for PocketMine-MP and PHP projects
License MIT
Informations about the package libasync
libasync
libasync is a lightweight asynchronous library designed primarily
for PocketMine-MP, but fully general-purpose. It supports seamless
multitasking, cooperative coroutines, and even multi-thread/multi-process execution in NTS environments without
code
changes.
Requirements and installation
- PHP 8.2 or later.
- PocketMine-MP API 5 when using the bundled
AsyncLoaderplugin entry point. - The Composer dependency
opis/closurefor closure serialization.
Install the library in a PHP project with Composer:
Composer autoload registers the library's public function entry points, so Composer consumers do not need to require internal function files manually.
For PocketMine-MP, load the plugin through the project's supported plugin or virion packaging workflow. The build metadata is still being validated against DevTools; the current repository does not claim that a standalone PHAR can automatically bundle every Composer package.
NTS Ready LITERALLY, you can use libasync without
ext-pthreadandext-pmmpthreadwith a trueprocess, you don't need any extra work.
🚀 Pain Points Solved
- Blocking Operations: Avoid server stalls caused by synchronous I/O or heavy computation.
- Complex Coroutine Management: Simplifies handling of async tasks, delays, timeouts, and resource pools.
- Thread/Process Safety: Enables concurrent execution without rewriting logic for multi-threaded or multi-process environments.
- Fine-grained Async Control: Provides awaitable results, cancellation, and timing primitives like ticks and event-loop aware delays.
🤔 Why Choose This System?
- PocketMine-MP Optimized: Tailored to Minecraft server internals for minimal overhead.
- Framework Agnostic: Works in any PHP project, not limited to PocketMine-MP.
- NTS Ready: Transparent support for non-thread-safe PHP builds with multi-process or multi-thread fallback.
- Flexible Event Loop: Easily integrate with existing loops or use built-in classic event loop.
- Lightweight & Minimal: No heavy dependencies; fully PSR-compatible design.
Features
- Coroutines: Easily write asynchronous code using
async()andthread(). - Deferred Execution: Register deferred closures to be executed when a coroutine finishes (
defer()). - Traps: Add trap closures that trigger under specific conditions (
trap(),trap_online()). - Timeouts: Set timeouts for coroutine tasks (
timeout()). - Coroutine Lifecycle Control:
joined()ensures a coroutine runs to completion, even during shutdown.may_drop()allows a coroutine to be dropped immediately if not critical.
- Safe Closures: Detect and prevent cyclic references in closures using
ClosureUtils::noCyclic().