Download the PHP package vectorial1024/laravel-process-async without Composer

On this page you can find all versions of the php package vectorial1024/laravel-process-async. 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 laravel-process-async

laravel-process-async

Packagist License Packagist Version Packagist Downloads PHP Dependency Version GitHub Repo Stars

Utilize Laravel Processes to run PHP code asynchronously, as if using Laravel Concurrency.

What really is this?

Laravel Processes was first introduced in Laravel 10. This library wraps around Process::start() to let you execute code in the background to achieve async, albeit with some caveats:

This library internally uses an Artisan command to run the async code, which is similar to Laravel 11 Concurrency.

Why should I want this?

This library is very helpful for these cases:

Of course, if you are considering extreme scaling (e.g. Redis queues in Laravel, multi-worker clusters, etc.) or guaranteed task execution, then this library is obviously not for you.

Installation

via Composer:

This library supports Unix and Windows; see the Testing section for more details.

Extra requirements for Unix

If you are on Unix, check that you also have the following:

Change log

Please see CHANGELOG.md.

Example code and features

Tasks can be defined as PHP closures, or (recommended) as an instance of a class that implements AsyncTaskInterface.

A very simple example task to write Hello World to a file:

Task time limits

You can set task time limits before you start them, but you cannot change them after the tasks are started. When the time limit is reached, the async task is killed.

The default time limit is 30 real seconds. You can also choose to not set any time limit, in this case the (CLI) PHP max_execution_time directive will control the time limit.

Note: AsyncTaskInterface contains an implementable method handleTimeout for you to define timeout-related cleanups (e.g. write to some log that the task has timed out). This method is still called when the PHP max_execution_time directive is triggered.

Some tips:

Task IDs

You can assign task IDs to tasks before they are run, but you cannot change them after the tasks are started. This allows you to track the statuses of long-running tasks across web requests.

By default, if a task does not has its user-specified task ID when starting, a ULID will be generated as its task ID.

Some tips:

Securing the task runners

The way this library works means that attackers (or other unwanted parties) may simply craft malicious commands that mimic legitimate usage of this library.

To secure the task runners from being started illegitimately, you may configure the .env file to contain the following key:

You may need to clear your Laravel optimisation cache after changing this value.

The contents of the async tasks will be signed by this secret key, so that this library can know whether the tasks are started by this library itself or someone else.

Fake Objects

Fake objects are available for users to simulate async task behaviors without actually starting async tasks. This should be helpful when writing tests that attempts to react to task statuses.

The following fake objects are available:

Notably, they can be used like this:

Testing

PHPUnit via Composer script:

Latest cross-platform testing results: Runtime MacOS Ubuntu Windows
Laravel 10 (PHP 8.1) skipped* skipped* skipped*
Laravel 11 (PHP 8.2) Build-M-L11 Build-U-L11 Build-W-L11
Laravel 12 (PHP 8.3) Build-M-L12 Build-U-L12 Build-W-L12
Laravel 13 (PHP ???) 🛠️ 🛠️ 🛠️

*Note: tests for these Laravel versions are skipped because they have old artisan file contents:


All versions of laravel-process-async with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version ^10.0|^11.0|^12.0
loophp/phposinfo Version ^1.8
opis/closure Version ^4.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 vectorial1024/laravel-process-async contains the following files

Loading the files please wait ...