This repository provides a Docker-based workspace that includes Traefik, Nginx/Apache, SSL certificates, MailHog, Elasticsearch, MySQL, and Redis.
- In
traefik
directory, run:
docker network create proxy
docker-compose up -d
- Visit
traefik.localhost
in your browser.
- In
mysql8
andmysql57
directories, run:
docker-compose up -d
- Access MySQL via MySQL Workbench, TablePlus, HeidiSQL, etc., using the following:
mysql8
: Hostname127.0.0.1
, Port3306
mysql57
: Hostname127.0.0.1
, Port3307
- In
mailhog
directory, run:
docker-compose up -d
- Visit
mailhog.localhost
in your browser.
- In the
elasticsearch
directory, run:
docker-compose up -d
- To connect to Elasticsearch, use the hostname
elasticsearch
.
- Clone a recipe from the
recipes
directory into theprojects
directory. - Rename the directory, e.g.,
newproject1
. - Edit the
.env
file to name your project, preferably using the same name as the directory. - Place your application files into the
src
directory. - In the project directory, run:
docker-compose up -d
This is one time step. MiniCA will create certificates automatically for each new project.
- Copy
traefik/certificates/minica.pem
to your local machine - Run command
openssl x509 -outform der -in minica.pem -out minica.crt
- Right click
minica.crt
- Install certificate -> Place certificate in the following store -> Trusted Root Certification Authorities
- Restart browser
After making changes to containers, run:
docker-compose up -d --build --force-recreate
For the mysql57
container, data is stored in the mysql57/data
directory.
For the mysql8
container, data is stored in the mysql8/data
directory.
To connect to the MySQL container in your project, use mysql57
or mysql8
as the hostname. For example, in a WordPress configuration:
define('DB_NAME', 'newproject1');
define('DB_USER', 'root');
define('DB_PASSWORD', 'root');
define('DB_HOST', 'mysql8'); // Use the container name for MySQL 8.0
You can also set up each project with its own MySQL instance if specific configurations are needed. Ensure to use a unique port number (set up inside the .env
file). If using a predefined MySQL configuration, your project’s MySQL instance container should be named projectname-mysql
.
For the project's MySQL instance, data is stored inside the [project catalog]/.docker/mysql/data
directory.
Backup your data periodically to avoid data loss.
Replace APP_NAME
with your app name:
docker exec -it APP_NAME-php bash
composer install
Replace APP_NAME
with your app name:
docker exec -it APP_NAME-cli bash
wp help
Follow these steps for each of your projects:
- File -> Settings -> PHP -> Debug
- Xdebug port: 9003
- Tick 'Can accept external connections'
- File -> Settings -> PHP -> Servers
- Name: localhost
- Hostname localhost
- Tick 'Use path mapping'
- Set '/var/www/html' next to your projects
src
directory - Add breakpoints in your code
- Run -> Start listening for PHP Debug Connections
In chrome:
- Install the Xdebug helper extension
- Go to your project's URL
- Enable the extension
- Reload the page
Note: If you switch projects, remember to turn off listening for connections in the project you are no longer working on. Otherwise, the debugger might open in the wrong window.