zero-to-prod / dock
Docker files for running a basic PHP application.
Maintainers
Details
Fund package maintenance!
Github
Installs: 2 840
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Language:Dockerfile
Requires
- php: >=7.1
- zero-to-prod/package-helper: ^1.1.3
This package is auto-updated.
Last update: 2025-09-01 22:44:54 UTC
README
Contents
- Introduction
- Supported Php Versions
- Prerequisites
- Installation
- Documentation Publishing
- Initialization
- Usage
Introduction
Dock provides a Docker powered local development experience for a PHP application. Other than Docker, no software or libraries are required to be installed on your local computer before using Dock. Dock's simple CLI means you can start building your PHP application without any previous Docker experience.
Why you’ll love it:
- Test Multiple PHP Versions with one script.
- Switch Versions Easily via
.env
settings.- Comprehensive Docker Support through docker-compose.
- PHP Debugging already setup across all supported versions.
- Available with Composer.
Supported PHP Versions
Compatible with PHP:
- 7.1
- 7.2
- 7.3
- 7.4
- 8.0
- 8.1
- 8.2
- 8.3
- 8.4
- 8.5
Prerequisites
- Docker installed and running
Installation
Add dock
to your project with Composer:
composer require zero-to-prod/dock --dev
Documentation Publishing
You can publish this README to your local documentation directory.
This can be useful for providing documentation for AI agents.
This can be done using the included script:
# Publish to default location (./docs/zero-to-prod/dock) vendor/bin/zero-to-prod-dock # Publish to custom directory vendor/bin/zero-to-prod-dock /path/to/your/docs
Automatic Documentation Publishing
You can automatically publish documentation by adding the following to your composer.json
:
{ "scripts": { "post-install-cmd": [ "zero-to-prod-dock" ], "post-update-cmd": [ "zero-to-prod-dock" ] } }
Initialization
Once you have the composer package installed, you can set up Dock in your project directory:
./vendor/bin/dock
This copies necessary configuration files to your project.
Usage
Dock includes scripts to build and manage your PHP environments effortlessly.
Configuration
Before starting development, verify that your .env
file contains the correct settings.
You can specify which PHP version to use for local development, debugging, and Composer operations by updating these variables in your .env
file:
PHP_VERSION=8.1 PHP_DEBUG=8.1 PHP_COMPOSER=8.1
Building Containers
Build Docker containers based on your .env
PHP versions:
sh dock build
This will create the following containers:
- php<PHP_VERSION> (example service:
php7.1
) - debug<PHP_VERSION> (example service:
debug7.1
) - composer<PHP_VERSION> (example service:
composer7.1
)
Install Dependencies for a Runtime
Update Composer dependencies as defined in your .env
:
sh dock composer update
Commands
There a few commands that come with the default script.
sh dock build # Builds the php, debug, and composer containers sh dock init # Initialize the .env file from .env.example if it doesn't exist. sh dock test # Run PHPUnit tests using the specified PHP version. sh dock composer # Run Composer commands using the specified PHP version. sh dock <service> # Run a specified Docker service with optional arguments.