Download the PHP package clue/docker-react without Composer

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

clue/reactphp-docker

CI status installs on Packagist

Async, event-driven access to the Docker Engine API, built on top of ReactPHP.

Docker is a popular open source platform to run and share applications within isolated, lightweight containers. The Docker Engine API allows you to control and monitor your containers and images. Among others, it can be used to list existing images, download new images, execute arbitrary commands within isolated containers, stop running containers and much more. This lightweight library provides an efficient way to work with the Docker Engine API from within PHP. It enables you to work with its images and containers or use its event-driven model to react to changes and events happening.

Table of contents

Support us

We invest a lot of time developing, maintaining and updating our awesome open-source projects. You can help us sustain this high-quality of our work by becoming a sponsor on GitHub. Sponsors get numerous benefits in return, see our sponsoring page for details.

Let's take these projects to the next level together! 🚀

Quickstart example

Once installed, you can use the following code to access the Docker API of your local docker daemon:

See also the examples.

Usage

Client

The Client is responsible for assembling and sending HTTP requests to the Docker Engine API.

This class takes an optional LoopInterface|null $loop parameter that can be used to pass the event loop instance to use for this object. You can use a null value here in order to use the default loop. This value SHOULD NOT be given unless you're sure you want to explicitly use a given event loop instance.

If your Docker Engine API is not accessible using the default unix:///var/run/docker.sock Unix domain socket path, you may optionally pass an explicit URL like this:

Commands

All public methods on the Client resemble the API described in the Docker Engine API documentation like this:

Listing all available commands is out of scope here, please refer to the Docker Engine API documentation or the class outline.

Each of these commands supports async operation and either resolves with its results or rejects with an Exception. Please see the following section about promises for more details.

Promises

Sending requests is async (non-blocking), so you can actually send multiple requests in parallel. Docker will respond to each request with a response message, the order is not guaranteed. Sending requests uses a Promise-based interface that makes it easy to react to when a command is completed (i.e. either successfully fulfilled or rejected with an error):

If this looks strange to you, you can also use the more traditional blocking API.

Blocking

As stated above, this library provides you a powerful, async API by default.

You can also integrate this into your traditional, blocking environment by using reactphp/async. This allows you to simply await commands on the client like this:

Similarly, you can also process multiple commands concurrently and await an array of results:

This is made possible thanks to fibers available in PHP 8.1+ and our compatibility API that also works on all supported PHP versions. Please refer to reactphp/async for more details.

Command streaming

The following API endpoints resolve with a buffered string of the command output (STDOUT and/or STDERR):

Keep in mind that this means the whole string has to be kept in memory. If you want to access the individual output chunks as they happen or for bigger command outputs, it's usually a better idea to use a streaming approach.

This works for (any number of) commands of arbitrary sizes. The following API endpoints complement the default Promise-based API and return a Stream instance instead:

The resulting stream is a well-behaving readable stream that will emit the normal stream events:

Note that by default the output of both STDOUT and STDERR will be emitted as normal data events. You can optionally pass a custom event name which will be used to emit STDERR data so that it can be handled separately. Note that the normal streaming primitives likely do not know about this event, so special care may have to be taken. Also note that this option has no effect if you execute with a TTY.

See also the exec benchmark example.

The TTY mode should be set depending on whether your command needs a TTY or not. Note that toggling the TTY mode affects how/whether you can access the STDERR stream and also has a significant impact on performance for larger streams (relevant for hundreds of megabytes and more). See also the TTY mode on the execStart*() call.

Running the provided benchmark example on a range of systems, it suggests that this library can process several gigabytes per second and may in fact outperform the Docker client and seems to be limited only by the Docker Engine implementation. Instead of posting more details here, you're encouraged to re-run the benchmarks yourself and see for yourself. The key takeway here is: PHP is faster than you probably thought.

TAR streaming

The following API endpoints resolve with a string in the TAR file format:

Keep in mind that this means the whole string has to be kept in memory. This is easy to get started and works reasonably well for smaller files/containers.

For bigger containers it's usually a better idea to use a streaming approach, where only small chunks have to be kept in memory. This works for (any number of) files of arbitrary sizes. The following API endpoints complement the default Promise-based API and return a Stream instance instead:

Accessing individual files in the TAR file format string or stream is out of scope for this library. Several libraries are available, one that is known to work is clue/reactphp-tar.

See also the export example.

JSON streaming

The following API endpoints take advantage of JSON streaming:

What this means is that these endpoints actually emit any number of progress events (individual JSON objects). At the HTTP level, a common response message could look like this:

The user-facing API hides this fact by resolving with an array of all individual progress events once the stream ends:

Keep in mind that due to resolving with an array of all progress events, this API has to keep all event objects in memory until the Promise resolves. This is easy to get started and usually works reasonably well for the above API endpoints.

If you're dealing with lots of concurrent requests (100+) or if you want to access the individual progress events as they happen, you should consider using a streaming approach instead, where only individual progress event objects have to be kept in memory. The following API endpoints complement the default Promise-based API and return a Stream instance instead:

The resulting stream will emit the following events:

See also the push example.

Install

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

This project follows SemVer. This will install the latest supported version:

See also the CHANGELOG for details about version upgrades.

This project aims to run on any platform and thus does not require any PHP extensions and supports running on legacy PHP 5.3 through current PHP 8+. It's highly recommended to use the latest supported PHP version for this project.

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

This project is released under the permissive MIT license.

Did you know that I offer custom development services and issuing invoices for sponsorships of releases and for contributions? Contact me (@clue) for details.


All versions of docker-react with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
clue/json-stream Version ^0.1
react/event-loop Version ^1.2
react/http Version ^1.8
react/promise Version ^3.1 || ^2.11 || ^1.3
react/promise-stream Version ^1.6
react/socket Version ^1.12
react/stream Version ^1.2
rize/uri-template Version ^0.3
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 clue/docker-react contains the following files

Loading the files please wait ....