How to Set Up a Full PHP Development Environment with Laradock Docker

This guide introduces Laradock, a Docker‑based PHP development environment, outlines its key features, and provides step‑by‑step commands to clone the repository, configure the .env file, and launch containers for services like NGINX, MySQL, and Redis.

Open Source Tech Hub
Open Source Tech Hub
Open Source Tech Hub
How to Set Up a Full PHP Development Environment with Laradock Docker

Introduction

Laradock is a complete Docker‑based local development environment for PHP, similar to Homestead, offering pre‑configured Docker images that simplify running PHP applications.

Initially created for Laravel, Laradock has expanded to support many PHP projects such as Symfony, CodeIgniter, WordPress, and Drupal.

Features

Easy switching among PHP versions (8.3, 8.2, 8.1, 7.4, 7.3, 7.2, 7.1, 5.6, etc.)

Choice of database engines (MySQL, Postgres, MariaDB, …)

Optional software stacks (Memcached, HHVM, Beanstalkd, …)

Each service runs in its own container (PHP‑FPM, NGINX, PHP‑CLI, …)

Simple customization by editing Dockerfiles

All images extend official base images, ensuring security and reliability

Environment variables can install or remove software inside containers

Clean, well‑structured Dockerfiles

Everything is visible and editable

Usage

Create a Laravel project (example command):

composer create-project laravel/laravel Tinywan-app "5.2.*"

Clone the Laradock repository:

git clone https://github.com/laradock/laradock.git

Enter the cloned directory: cd laradock/ Copy the example environment file and adjust it for local mirrors if needed:

cp .env.example .env
# If you need to change the sources (i.e. to China), set CHANGE_SOURCE to true
CHANGE_SOURCE=true

Start the required containers with Docker Compose: docker-compose up -d nginx mysql redis The NGINX container is built on top of the php‑fpm image, which itself is built on the workspace image; therefore NGINX will start after workspace and php‑fpm are ready.

If a specified port is already in use, stop the conflicting service and rerun the command.

In the Laravel project's .env file, add the following configuration: <code>DB_HOST=mysql REDIS_HOST=redis QUEUE_HOST=beanstalkd</code>
Open a browser and visit localhost to see the running application.
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockerDevelopment EnvironmentPHPDocker ComposeLaravelLaradock
Open Source Tech Hub
Written by

Open Source Tech Hub

Sharing cutting-edge internet technologies and practical AI resources.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.