Download the PHP package arara/process without Composer

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

Arara\Process

Build Status Code Quality Code Coverage Latest Version Total Downloads License

This library provides a better API to work with processes on Unix-like systems using PHP.

Installation

The package is available on Packagist. You can install it using Composer.

Dependencies

Version 1.6.0 or less of Arara\Process works on PHP 5.3.

Usage

Along with this document, there are many usage examples in the examples/ directory which may be used for reference.

All examples within this document assume you have the following statement at the beginning of the file:

Without this statement, there is no guarantee PHP will handle signals; this is very important for PCNTL to work properly. It has been required since version 4.3.0 of PHP, so this is not a request of the library but of the PHP language itself.

If you want to know more about ticks, we recommend you read http://php.net/declare#control-structures.declare.ticks.

Action interface

Forks may be encapsulated using Arara\Process\Action\Action interface. All classes that implements this interface must implement two methods:

Using this interface you can create your own actions and run them in the background.

Events

The Arara\Process\Action\Action::trigger(..) method, as it is written, associates specific actions with events. Those events can be:

Callback action

In order to make it easy to execute forks with no need to create a specific class to execute something in the background, there is a generic implementation that allows a callback to be run in the background; the only thing one must do is pass the callback to the constructor of this class.

The Callback action provides a way to bind callbacks to be triggered by specific events:

Also, one can bind a callback to multiple events:

Command action

You may want to run just a Linux command, for that reason there is Command action.

Using Command action you can define arguments as second param:

If you prefer arguments can be defined by a key => value array:

Command action is based on Callback action so you can also bind triggers for events.

Daemon action

You can create daemons using the Arara\Process\Action\Daemon class:

This action will:

  1. Detach process session from the parent
  2. Update process umask
  3. Update process work directory
  4. Define process GID (if defined)
  5. Define process UID (if defined)
  6. Recreate standards file descriptors (STDIN, STDOUT and STDERR)
  7. Create Pidfile
  8. Run the defined payload callback

Daemon action is based on Callback action thus you can also bind triggers for events.

Daemon options

Daemon action class has some options that allows you to change some behaviours:

You can change default daemon options by defining it on class constructor:

After the object is created you may change all options:

Also you can change just an option:

Starting a process in the background

The class Arara\Process\Child allows you to execute any action in the background.

The above example runs the Daemon action in the background, but one can use any class which implements the Arara\Process\Action\Action interface like Callback action.

Check if the process is running

Checking to see if a process is running is a very common routine; to perform this using this library you may call:

This method not only checks the state of the object, but also checks to see if the process is already running on the system.

Terminating the process

If the process has already started, this tells the process to terminate, but does not force it.

Killing the process

If it has already started, this forces the process to terminate immediately.

Waiting on the process

If you want to wait on the process to finish, instead of just starting the process in the background, you can call:

The next line of code will be executed after the process finishes.

Getting a process' status

It is possible to get the status of a process after waiting for it finish. The Arara\Process\Child class has a method getStatus() which allows you to check the status of a process.

Internally, this calls the wait() method, in order to wait for the process to finish - and then get its status.

Get the exit code of the process

Get the signal which caused the process to stop

Get the signal which caused the process to terminate

Checks if the status code represents a normal exit

Checks whether the status code represents a termination due to a signal

Checks whether the process is stopped

Checks if the process was finished successfully

Spawning

Since you are working with forks you are able work with spawn as well. The Arara\Process\Pool class provides a simple way to work with it.

This class handles the queue of process dynamically, the only thing you have to do is provide the limit of children you want in the constructor and then attach the children.

The number of children it has does not matter; it will only run 2 process simultaneously; when one of those process is finished, it is removed from the queue and a new slot is opened.

The Arara\Process\Pool class contains most of the methods of Arara\Process\Child class:

This behaves similarly for all methods.

Control class

You can also handle processes without using Pool, Child or the Action classes.

We provide a simple API to work with the pcntl_* and posix_* functions. You can learn more by reading the code of Arara\Process\Control and its dependencies, but here is an example:

Pidfile class

If you are working with background tasks you may want to create a lock to avoid people running your script twice. For this purpose there is the class Arara\Process\Pidfile.

The second time someone runs it an exception is thrown. We recommend you put this code into a try..catch statement.


All versions of process with dependencies

PHP Build Version
Package Version
Requires ext-pcntl Version *
ext-posix Version *
php Version >=5.4.0
phpfluent/callback 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 arara/process contains the following files

Loading the files please wait ....