Download the PHP package tiny-blocks/docker-container without Composer

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

Docker container

Overview

Manages Docker containers programmatically for PHP, enabling integration tests and disposable infrastructure to be orchestrated directly from code. Supports container definitions, port and volume mappings, environment variables, readiness probes, shutdown hooks, and orphan reaping.

Installation

How to use

Creating a container

Creates a container from a specified image and an optional name.

Running a container

Starts a container. Optionally accepts commands to run on startup and a wait strategy applied after the container starts.

With commands:

With commands and a wait strategy:

Running if not exists

Starts a container only if a container with the same name is not already running.

Pulling images in parallel

Calling pullImage() starts downloading the image in the background via a non-blocking process. When run() or runIfNotExists() is called, it waits for the pull to complete before starting the container.

To pull multiple images in parallel, call pullImage() on all containers before calling run() on any of them. This way the downloads happen concurrently:

Setting network

Sets the Docker network the container should join. The network is created automatically when the container is started via run() or runIfNotExists(), if it does not already exist. Networks created by the library are labeled with tiny-blocks.docker-container=true for safe cleanup.

Setting port mappings

Maps a port from the host to the container.

After the container starts, both ports are available through the Address:

Setting volume mappings

Mounts a directory from the host into the container.

Setting environment variables

Adds an environment variable to the container.

Disabling auto-remove

By default, containers are removed when stopped. This disables that behavior.

Copying files to a container

Registers files or directories to be copied from the host into the container after it starts.

Stopping a container

Stops a running container. An optional timeout (in seconds) controls how long to wait before forcing the stop. The default timeout is 300 seconds.

With a custom timeout:

Stopping on shutdown

Registers the container to be forcefully removed when the PHP process exits. On shutdown, the following cleanup is performed automatically:

Only resources labeled with tiny-blocks.docker-container=true are affected. Containers, volumes, and networks from other environments are never touched.

Executing commands after startup

Runs commands inside an already-started container.

The returned ExecutionCompleted provides the command output and success status:

Wait strategies

Waiting for a fixed time

Pauses execution for a specified number of seconds before or after starting a container.

Waiting for a dependency

Blocks until a readiness condition is satisfied, with a configurable timeout. This is useful when one container depends on another being fully ready.

MySQL container

MySQLDockerContainer provides a specialized container for MySQL databases. It extends the generic container with MySQL-specific configuration and automatic readiness detection.

Configuring MySQL options

Method Parameter Description
withTimezone $timezone Sets the container timezone (e.g., America/Sao_Paulo).
withUsername $user Sets the MySQL user created on startup.
withPassword $password Sets the password for the MySQL user.
withDatabase $database Sets the default database created on startup.
withRootPassword $rootPassword Sets the root password for the MySQL instance.
withGrantedHosts $hosts Sets hosts granted root privileges (default: ['%', '172.%']).

Setting readiness timeout

Configures how long the MySQL container waits for the database to become ready before throwing a ContainerWaitTimeout exception. The default timeout is 30 seconds.

Retrieving connection data

After the MySQL container starts, connection details are available through the MySQLContainerStarted instance.

Use firstExposedPort() when connecting from another container in the same network. Use firstHostPort() when connecting from the host machine (e.g., tests running outside Docker).

Environment-aware connection

The Address and Ports contracts provide environment-aware methods that automatically resolve the correct host and port for connecting to a container. These methods detect whether the caller is running inside Docker or on the host machine:

This is useful when the same test suite runs both locally (inside a Docker Compose stack) and in CI (on the host). Instead of manually checking the environment and switching between getHostname()/getIp() or firstExposedPort()/ firstHostPort(), the environment-aware methods handle it transparently.

Flyway container

FlywayDockerContainer provides a specialized container for running Flyway database migrations. It encapsulates Flyway configuration, database source detection, and migration file management.

Setting the database source

Configures the Flyway container to connect to a running MySQL container. Automatically detects the JDBC URL and target schema from MYSQL_DATABASE, and sets the history table to schema_history.

The schema and table can be overridden after calling withSource():

Configuring migrations

Sets the host directory containing Flyway migration SQL files. The files are copied into the container at /flyway/migrations.

Configuring Flyway options

Method Parameter Description
withTable $table Overrides the history table name (default: schema_history).
withSchema $schema Overrides the target schema (default: auto-detected from MySQL).
withCleanDisabled $disabled Enables or disables Flyway's clean command.
withConnectRetries $retries Sets the number of database connection retries.
withValidateMigrationNaming $enabled Enables or disables migration naming validation.

Running Flyway commands

Method Flyway command Description
migrate() migrate Applies pending migrations.
validate() validate Validates applied migrations against local.
repair() repair Repairs the schema history table.
cleanAndMigrate() clean migrate Drops all objects and re-applies migrations.

Usage examples

MySQL with Flyway migrations

Configure both containers and start image pulls in parallel before running either one:

License

Docker container is licensed under MIT.

Contributing

Please follow the contributing guidelines to contribute to the project.


All versions of docker-container with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
symfony/process Version ^8.0
tiny-blocks/collection Version ^2.3
tiny-blocks/ksuid Version ^1.5
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 tiny-blocks/docker-container contains the following files

Loading the files please wait ...