spatie/docker
Start and manage Docker containers from PHP. Create and run containers, execute commands inside them, and capture output. Customize behavior like daemonization, auto-cleanup on exit, and privileged mode for more control.
Adopt if:
Look elsewhere if:
For Executives: "This package lets us automate Docker container management directly in our PHP test suites—eliminating manual setup, reducing CI/CD costs, and ensuring tests run in consistent, isolated environments. For example, we can test against PostgreSQL 15 and 16 in the same pipeline without extra infrastructure. It’s a low-risk, high-reward way to modernize our test infrastructure, with minimal dev overhead since it’s maintained by Spatie (the same team behind Laravel-friendly packages like Laravel-Permission)."
For Engineering/DevOps: *"Spatie’s Docker package gives us a PHP-native way to start/stop containers in tests, with a clean API:
$container = DockerContainer::create('postgres:15')->start();
$container->execute('psql -c \"SELECT 1\"'); // Test queries
@beforeTest setup).How can I help you explore Laravel packages today?