Download the PHP package nick4fake/react-child-process without Composer

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

Child Process Component

Build Status Code Climate

Library for executing child processes.

This library integrates Program Execution with the EventLoop. Child processes launched may be signaled and will emit an exit event upon termination. Additionally, process I/O streams (i.e. STDIN, STDOUT, STDERR) are exposed as Streams.

Table of contents

Quickstart example

See also the examples.

Processes

EventEmitter Events

Methods

There are additional public methods on the Process class, which may be used to access fields otherwise available through proc_get_status().

Stream Properties

Once a process is started, its I/O streams will be constructed as instances of React\Stream\Stream. Before start() is called, these properties are null. Once a process terminates, the streams will become closed but not unset.

Each of these implement the underlying DuplexStreamInterface and you can use any of its events and methods as usual:

For more details, see the DuplexStreamInterface.

Command

The Process class allows you to pass any kind of command line string:

By default, PHP will launch processes by wrapping the given command line string in a sh command, so that the above example will actually execute sh -c echo test under the hood.

This is a very useful feature because it does not only allow you to pass single commands, but actually allows you to pass any kind of shell command line and launch multiple sub-commands using command chains (with &&, ||, ; and others) and allows you to redirect STDIO streams (with 2>&1 and family). This can be used to pass complete command lines and receive the resulting STDIO streams from the wrapping shell command like this:

In other words, the underlying shell is responsible for managing this command line and launching the individual sub-commands and connecting their STDIO streams as appropriate. This implies that the Process class will only receive the resulting STDIO streams from the wrapping shell, which will thus contain the complete input/output with no way to discern the input/output of single sub-commands.

If you want to discern the output of single sub-commands, you may want to implement some higher-level protocol logic, such as printing an explicit boundary between each sub-command like this:

As an alternative, considering launching one process at a time and listening on its exit event to conditionally start the next process in the chain. This will give you an opportunity to configure the subsequent process I/O streams:

Keep in mind that PHP uses the shell wrapper for ALL command lines. While this may seem reasonable for more complex command lines, this actually also applies to running the most simple single command:

This will actually spawn a command hierarchy similar to this:

This means that trying to get the underlying process PID or sending signals will actually target the wrapping shell, which may not be the desired result in many cases.

If you do not want this wrapping shell process to show up, you can simply prepend the command string with exec, which will cause the wrapping shell process to be replaced by our process:

This will show a resulting command hierarchy similar to this:

This means that trying to get the underlying process PID and sending signals will now target the actual command as expected.

Note that in this case, the command line will not be run in a wrapping shell. This implies that when using exec, there's no way to pass command lines such as those containing command chains or redirected STDIO streams.

As a rule of thumb, most commands will likely run just fine with the wrapping shell. If you pass a complete command line (or are unsure), you SHOULD most likely keep the wrapping shell. If you want to pass an invidual command only, you MAY want to consider prepending the command string with exec to avoid the wrapping shell.

Sigchild Compatibility

When PHP has been compiled with the --enabled-sigchild option, a child process' exit code cannot be reliably determined via proc_close() or proc_get_status(). Instead, we execute the child process with a fourth pipe and use that to retrieve its exit code.

This behavior is used by default and only when necessary. It may be manually disabled by calling setEnhanceSigchildCompatibility(false) on the Process before it is started, in which case the exit event may receive null instead of the actual exit code.

Note: This functionality was taken from Symfony's Process compoment.

Install

The recommended way to install this library is through Composer. New to Composer?

This will install the latest supported version:

More details about version upgrades can be found in the CHANGELOG.

Tests

To run the test suite, you first need to clone this repo and then install all dependencies through Composer:

To run the test suite, go to the project root and run:

License

MIT, see LICENSE file.


All versions of react-child-process with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
evenement/evenement Version ^2.0 || ^1.0
react/event-loop Version ^0.4 || ^0.3
react/stream Version ^0.5 || ^0.4.4
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 nick4fake/react-child-process contains the following files

Loading the files please wait ....