PHPackages                             krypt0nn/asynclib - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. krypt0nn/asynclib

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

krypt0nn/asynclib
=================

library that gives you ability to create asynchronous tasks in PHP 7.4+

0.2.1(4y ago)29GPL-3.0-or-laterPHPPHP &gt;=7.4

Since Aug 7Pushed 4y ago2 watchersCompare

[ Source](https://github.com/krypt0nn/asynclib)[ Packagist](https://packagist.org/packages/krypt0nn/asynclib)[ Docs](https://github.com/KRypt0nn/asynclib)[ RSS](/packages/krypt0nn-asynclib/feed)WikiDiscussions main Synced today

READMEChangelog (3)DependenciesVersions (4)Used By (0)

🚀 Asynclib
==========

[](#-asynclib)

**Asynclib** is a library that gives you ability to create asynchronous tasks in PHP 7.4+

Installation
------------

[](#installation)

```
composer require krypt0nn/asynclib

```

About asynchronous programming
------------------------------

[](#about-asynchronous-programming)

[![](https://camo.githubusercontent.com/8ddd08bcd4d007a44f9657812b635d2674ea862c3ba99046076b5e2704f4a415/68747470733a2f2f692e6962622e636f2f50476e394458302f556e7469746c65642d4469616772616d2e706e67)](https://camo.githubusercontent.com/8ddd08bcd4d007a44f9657812b635d2674ea862c3ba99046076b5e2704f4a415/68747470733a2f2f692e6962622e636f2f50476e394458302f556e7469746c65642d4469616772616d2e706e67)

\* yellows is a tasks ran asynchronously

This diagram shows the difference between synchronous and asynchronous programs. First ones executing every task in the main process so if you have a task like get a huge file from a website - the program will be paused (lagged) until this task will be not finished. It also means that other tasks in your program will be executed only after this one

Asynchronous programs execute tasks parallel. In Asynclib, every new task runs in another process which means that they will not affect the main program and stop its execution. We can run long high weight tasks async and monitor their states from the main process which will give us a valuable performance boost

Basic usage
-----------

[](#basic-usage)

> For practical example you can look at [test](/test) directory
>
> Also, keep in mind that this library was developed only for desktop usage. I didn't test it on websites and don't know will it works there or not

Every task should be written in its file. This file should return the `TaskRunner` object. For example:

```
