documentContainers

README.md

Containers

Container definitions for testcontainers-php used across k-kinzal/ztd-query-php. Each definition pins one image version, and every package that runs a container uses the same definition from the Container namespace.

Versions

ClassImage
MySql56Containermysql:5.6.51
MySql57Containermysql:5.7.44
MySql80Containermysql:8.0.44
MySql81Containermysql:8.1.0
MySql82Containermysql:8.2.0
MySql83Containermysql:8.3.0
MySql84Containercontainer-registry.oracle.com/mysql/community-server:8.4.7
MySql90Containercontainer-registry.oracle.com/mysql/community-server:9.0.1
MySql91Containercontainer-registry.oracle.com/mysql/community-server:9.1.0
PostgreSql16Containerpostgres:16.6
PostgreSql17Containerpostgres:17.2

Usage

use Container\Endpoint;
use Container\MySql80Container;
use Testcontainers\Testcontainers;

$endpoint = Testcontainers::run(MySql80Container::class)->getData(Endpoint::class);
$pdo = new PDO($endpoint->dsn(), $endpoint->username, $endpoint->password);

MySQL containers require pdo_mysql to wait for readiness.

Selecting a release

MySqlRelease and PostgreSqlRelease resolve a release number to its container. fromEnvironment() reads MYSQL_VERSION or PG_VERSION and falls back to the default release (8.4.7 and 17.2), so CI runs the newest release and any other release runs locally by setting the variable:

use Container\Endpoint;
use Container\MySqlRelease;
use Testcontainers\Testcontainers;

$endpoint = Testcontainers::run(MySqlRelease::fromEnvironment())->getData(Endpoint::class);
$ MYSQL_VERSION=8.0.44 vendor/bin/phpunit
$ PG_VERSION=16.6 vendor/bin/phpunit

container($version) resolves a release given in code, versions() lists the releases with a container, and latest() names the newest one.