PHP code example of k-kinzal / testcontainers-php
1. Go to this page and download the library: Download k-kinzal/testcontainers-php library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
k-kinzal / testcontainers-php example snippets
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
}
}