k-kinzal/testcontainers-php

PHP library for Testcontainers

Maintainers

👁 kinzal

Package info

github.com/k-kinzal/testcontainers-php

pkg:composer/k-kinzal/testcontainers-php

Statistics

Installs: 21 015

Dependents: 4

Suggesters: 0

Stars: 6

Open Issues: 1

v0.6.1 2026-03-25 11:30 UTC

Requires

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 3adfe9e5bcee6aa12d41973d2a80ac76167cc40a

  • k-kinzal <keen.flag7803.woop@logn.in>

README

👁 GitHub Actions
👁 CircleCI
👁 License: MIT

A PHP implementation of Testcontainers that supports PHP versions from 5.6 to 8.5, including EOL versions. This library enables you to use Docker containers for your integration tests with minimal dependencies.

If you are using a supported PHP version, consider using the official testcontainers/testcontainers instead.

Features

  • Supports PHP 5.6 to 8.5 (including EOL versions)
  • Minimal dependencies for easy integration
  • Complete container lifecycle management
  • Various configuration options for containers
  • Multiple wait strategies to ensure services are ready
  • Support for remote Docker hosts and SSH port forwarding

Requirements

  • Docker command line tool (docker CLI)
  • PHP 5.6 or later

Installation

composer require --dev k-kinzal/testcontainers-php

Quick Start

<?php

use PHPUnit\Framework\TestCase;
use Testcontainers\Containers\GenericContainer\GenericContainer;
use Testcontainers\Testcontainers;

class MyContainer extends GenericContainer
{
 protected static $IMAGE = 'alpine:latest';
}

class MyTest extends TestCase
{
 public function test(): void
 {
 // Start the container and get the container instance
 $instance = Testcontainers::run(MyContainer::class);
 
 // Your test code here
 
 // Containers are automatically stopped when the test ends
 }
}

Documentation

For more detailed information, check out the documentation:

  • Getting Started: A comprehensive guide to installing and using testcontainers-php
  • Container Configuration: Learn how to configure containers with various settings
  • Environments: Understand how to configure testcontainers-php using environment variables
  • CI Setup: Guide for setting up testcontainers-php in CI environments (GitHub Actions, CircleCI)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

  • Testcontainers for the original concept and implementation in other languages
  • All contributors who have helped improve this project