Download the PHP package codespede/simple-multi-threader without Composer

On this page you can find all versions of the php package codespede/simple-multi-threader. 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 simple-multi-threader

Simple Multi Threader

A simple PHP Multithreader extension which is ready for use without any setups or configurations.

Installation

The preferred way to install this extension is through composer.

Either run

or add

to the require section of your composer.json.

How to use

If you want to run some code in the background, just provide it in a closure(anonymous function) to an object of the class Threader as below:

That's all, the Threader will create the required job files in the specified $jobsDir and will start a PHP process in the background executing your code. The main thread(code above and after $threader->thread...) will run without waiting for the sub-thread(code in the closure) to finish. You will also get the started job's id(an md5 string) as the return value of the method thread which you can use for debugging.

Any data returned from the closure function will be logged to a file with name smt_<jobId>.log in the default directory specified for logs: smt-logs.

For examples, click here

Configurable Options

$arguments - Arguments for the closure - type: mixed, default = null

$jobsDir - Directory(auto-created if not existing) where temporary job files will be stored - type: string, default = "smt-jobs"

$logsDir - Directory(auto-created if not existing) where log files will be stored - type: string, default = "smt-logs"

$nohup - Whether to ignore the HUP (hangup) signal in Unix based systems - type: boolean, default = true

$helperClass - Fully qualified class name of the Helper to be used. - type: string, default = "cs\\simplemultithreader\\CommandHelper"

Any option above can be used to configure the Threader in the below way:

or like:

Making it compatible with the platform you use

Even if your application is not built either on Core PHP, Laravel or Yii2 which are already supported, you can make it compatible with this extension by the below steps:

There are two ways to accomplish this:

  1. Easiest way - Insert the bootstrap code of your Platform before your code in the closure.

  2. Recommended way - Extend $helperClass with your own Helper class and include the corresponding bootstrap function in it as below:

    Suppose the platform you use is WordPress. Create a function in the extended Class as below:

    and override the getPlatform method to just return the string 'wordpress'(as WordPress is the only platform you use in that app) as below:

    That's all! executeWordpressBootStrap will be executed before executing your code allowing Wordpress's native functions and usages in your code inside the Closure.

    By doing this just once, the extension is now ready for executing any code(normal and platform related) anywhere in your application. You're also getting the freedom to override any additional logic defined in the CommandHelper class.

    Pull Requests for supporting additional platforms are always welcome!

Debugging

Whenever an exception gets thrown from your code provided in the closure, it will be logged with a filename: smt_<jobId>_error.log. You can find the details of the error including the Stack Trace inside it.


All versions of simple-multi-threader with dependencies

PHP Build Version
Package Version
Requires opis/closure Version *
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 codespede/simple-multi-threader contains the following files

Loading the files please wait ....