Download the PHP package hds-solutions/parallel-sdk without Composer

On this page you can find all versions of the php package hds-solutions/parallel-sdk. 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 parallel-sdk

Parallel SDK

An implementation of krakjoe/parallel PHP extension.

Latest stable version License Total Downloads Monthly Downloads Required PHP version

PHP 8.0 PHP 8.1 PHP 8.2 PHP 8.3 PHP 8.4

This library is designed to work even if the parallel extension isn't available. In that case, the tasks will be executed un sequential order. That allow that your code can be deployed in any environment, and if parallel is enabled you will get the advantage of parallel processing.

Installation

Dependencies

You need these dependencies to execute tasks in parallel.

Parallel extension documentation can be found on https://php.net/parallel.

Through composer

Usage

You should set the bootstrap file for the parallel threads. Setting the composer's autoloader is enough.

Behind the scenes, the parallel extension creates an empty Runtime (thread) where the tasks are executed. Every Runtime is a clean, empty, isolated environment without any preloaded classes, functions, or autoloaders from the parent thread/process. This isolation ensures that each runtime starts with a minimal footprint. See references #2 for more info.

Then you define a Worker that will process the tasks. There are two options:

  1. Using an anonymous function as a Worker.
  2. Creating a class that extends from ParallelWorker and implements the process() method.

Then you can schedule tasks to run in parallel using Scheduler::runTask() method.

Bootstrap a Laravel app

Since ZTS is only available on the cli, you should set the bootstrap file for parallel threads in the artisan file.

Then, in the bootstrap file for the parallel threads, you just need to get an instance of the app and bootstrap the Laravel kernel. This way you will have all Laravel service providers registered. bootstrap/parallel.php:

Anonymous worker

Defining an anonymous function as a Worker to process the tasks.

Worker instance

Creating a class that extends from ParallelWorker class. This could be useful for complex processes and to maintain your code clean.

ExampleWorker.php:

You can also send parameters to the Worker's constructor.

Schedule tasks

After defining a Worker, you can schedule tasks that will run in parallel.

Check Tasks state

Every task has a state. There is also helper functions to check current Task state:

Wait for tasks completion

Instead of checking every task state, you can wait for all tasks to be processed before continue your code execution.

You can also specify a time limit for waiting. The process will pause until all tasks are processed or until max time has been reached, whatever comes first.

Get processed tasks result

Remove pending tasks

You can stop processing queued tasks if your process needs to stop earlier.

Remove a pending/running task

You can remove a specific task from the processing queue if you need to.

Stop processing all tasks immediately

If you need to stop all right away, you can call the Scheduler::stop() method. This will stop processing all tasks immediately.

Specifying the No. of CPU Cores

You can control the maximum percentage or number of CPU cores to use by calling the following methods:

ProgressBar

Requirements

Usage from Worker

Available methods are:

Example output

References

  1. parallel\bootstrap()
  2. parallel\Runtime
  3. Parallel\Runtime::run() Task Characteristics

Security Vulnerabilities

If you encounter any security-related issues, please feel free to raise a ticket on the issue tracker.

Contributing

Contributions are welcome! If you find any issues or would like to add new features or improvements, please feel free to submit a pull request.

Contributors

Licence

This library is open-source software licensed under the MIT License. Please see the License File for more information.


All versions of parallel-sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=8.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 hds-solutions/parallel-sdk contains the following files

Loading the files please wait ....