Download the PHP package mensbeam/fork without Composer

On this page you can find all versions of the php package mensbeam/fork. 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 fork

Fork

Fork is a library for running jobs concurrently in PHP. It works by forking the main process into separate tasks using PHP's pcntl and sockets extensions. So, it should go without saying that this library will not work on Windows.

There is an existing library for forking processes, spatie/fork. This library on its surface is very similar, but internally it's quite a bit different. Unlike spatie/fork, mensbeam/fork does not return an array of returned values from all tasks after all of them have finished. Instead, it uses callbacks to handle output as each task completes. This design prevents potential memory exhaustion when running a large number of tasks, as we encountered when using spatie/fork. Handling output immediately as tasks finish is more scalable and efficient.

Requirements

Installation

Install using Composer:

Usage

Here is a simple example. Fork->run() can accept an array or an \Iterator of callables to run concurrently and will execute them. This means it can also accept a generator to continuously run tasks concurrently.

Example output:


Callbacks

You can use before() and after() to register callbacks to run before or after each task. You can register different callbacks for the parent and child processes.


Concurrency

You can limit how many tasks run concurrently using concurrent().


Timeouts

You can set a timeout (in seconds) for each child process:

When a task times out, a TimeoutException is thrown inside the child process, and a ThrowableContext object is sent back to the parent.


Stopping tasks

You can stop all currently running and queued tasks from within an after() callback:


ThrowableContext

When a task throws an exception or error in a child process, a ThrowableContext instance is returned to the parent.

What it includes


Example


Handling traces

You can enable including stack traces in ThrowableContext objects:

Keep in mind there are some minor limitations, however. Anything that can't be serialized such as Generators, Closures, etc. are all sanitized to strings denoting what they were before being replaced.


Throwing exceptions inside the fork

By default, exceptions inside child processes are caught and sent as ThrowableContext objects. If you'd like them to be thrown, crash the child process, and therefore be printed (for debugging or crash reporting), set:

Example output:


License

MIT License. See AUTHORS.md for details.


All versions of fork with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-sockets Version *
ext-pcntl Version *
mensbeam/self-sealing-callable 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 mensbeam/fork contains the following files

Loading the files please wait ....