Docker files for running a basic PHP application.

Fund package maintenance!
Github

Installs: 508

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 0

Open Issues: 0

Language:Dockerfile

v1.0.27 2025-01-06 00:00 UTC

README

Repo Packagist Downloads Packagist Version GitHub repo size License Hits-of-Code wakatime

Contents

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

Prerequisites

  • Docker installed and running

Installation

Add dock to your project with Composer:

composer require zero-to-prod/dock --dev

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.