Download the PHP package sytxlabs/dockphp without Composer

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

DockPHP

Check code style Tests Latest Version on Packagist Total Downloads

Framework-agnostic PHP client for the Docker Engine API, talking directly to /var/run/docker.sock over HTTP (via Guzzle).

Contents

Installation

Quick start

Typed results

list() and inspect() on Containers, Images, Networks and Volumes return typed DTOs - not raw JSON - so you get autocompletion and don't have to remember Docker's field names:

Method Returns
containers()->list() list<DTO\ContainerSummary>
containers()->inspect() DTO\ContainerInfo
images()->list() list<DTO\ImageSummary>
images()->inspect() DTO\ImageInfo
networks()->list() / inspect() list<DTO\NetworkInfo> / DTO\NetworkInfo
volumes()->list() / inspect() list<DTO\VolumeInfo> / DTO\VolumeInfo

Every DTO only models the commonly-needed fields (id, name, state, labels, ...) - call ->raw() on any of them to get the full, untouched decoded array for anything not promoted to a typed property.

Every other resource method (start(), stop(), remove(), create(), ...) still returns a Sytxlabs\Dockphp\Http\DockerResponse - there's no useful entity to hydrate from an action's ack/204 response. Use ->json() for the decoded body or ->getBody() for the raw string.

Creating a container

containers()->create() accepts the full Docker container config as a single array. Query-only parameters (name, platform) are automatically split out of the array and sent as query string parameters, the rest is sent as the JSON request body - you never have to think about the split:

Networks and volumes

networks()->create() and volumes()->create() take the name directly, with an optional array of additional Docker options:

API version handling

By default, the API version is not fetched eagerly when you construct DockerClient - it is resolved lazily via a single GET /version call the first time a request is made, then cached for the lifetime of the client.

You can override it manually to skip that lookup entirely and pin a specific version:

Timeouts

Error handling

Security note

The Docker Engine API, reached through /var/run/docker.sock, grants practically full control over the Docker host. This package never changes socket permissions itself (no chmod, no ownership changes) - managing who can read/write that socket is entirely up to you and your deployment. Only grant access to the socket to trusted, trusted-equivalent code.

Streaming (logs, stats, pull/build progress, events)

Anything that can run indefinitely or produce output incrementally has a *Stream()/*Stream counterpart that invokes a callback per chunk instead of buffering the whole response. Return false from the callback to stop early:

pullStream()/buildStream()/events() already decode newline-delimited JSON for you via Sytxlabs\Dockphp\Support\NdjsonLineBuffer. logsStream() and attachStream() hand you raw bytes instead - see the demux section below.

Demultiplexing container logs

Unless a container was created with a TTY, Docker interleaves stdout and stderr into one stream using an 8-byte frame header per chunk of output. Sytxlabs\Dockphp\Support\StdioDemultiplexer decodes that format:

For logsStream()/attachStream(), use a stateful instance instead so frames split across chunks are handled correctly:

exec

Not supported: a fully interactive exec/attach session (writing to stdin while concurrently reading output). That needs a raw duplex socket outside of normal HTTP request/response semantics, which a per-call cURL client cannot provide. exec()->startStream() and containers()->attachStream() cover the read side; send a fixed block of input up front via the request body if you need to feed stdin.

TCP / TLS hosts

The Unix socket is the default and recommended way to connect. To reach a Docker Engine exposed over TCP instead (a remote host, or Docker Desktop's TCP endpoint):

Registry authentication (pull/push)

pull(), pullStream(), push() and pushStream() take an optional $registryAuth array - the usual Docker auth config (username/password/serveraddress, or identitytoken). It's sent as the base64-encoded X-Registry-Auth header Docker expects:

Testing

Integration tests automatically skip themselves when /var/run/docker.sock is not present (e.g. on Windows, or a machine without Docker installed) - no configuration required.

License

MIT - see LICENSE.


All versions of dockphp with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-curl Version *
ext-json Version *
guzzlehttp/guzzle Version ^7.9
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 sytxlabs/dockphp contains the following files

Loading the files please wait ...