Skip to content

theking2/docker-web-php-db-xdebug

Repository files navigation

setup for a complete lamp with xdebug

  1. Download the repositorys ZIP-file
  2. Create a project folder (this will contain the Webservers root htdocs and the server root (server) .
  3. Unzip the repo in a subfolder and rename it server
  4. move the folder htdocs and .vscode to the root of you project

The last step is not really needed but makes it a bit better readable. The folder structure at the end is:

projectname
├── htdocs <-- root of the webserver
├── logs <-- place for log files
└── server <-- apache, php and db server

Note

A configured xdebug.ini file sits in the server folder. It defaults to allow step debugging. After changing make sure to restart the webserver!

Setup docker containers

With Containers VSCode extension

  1. Install VScode extension "Container Tools"
  2. Update .env file (Setting network and Project)
  3. Open compose.yaml file and click "Run All Services"

After that the following services run with these uris>

URI Service
localhost:9080/ webroot, contents of folder = ./htdocs
localhost:3306 external db connection (change the port number in the .env if needed.)

Note

from inside the network the database connection is (still) db:3306!!

Setup environment

In .env

  1. copy .env_sample to .env
  2. set the project and network name.
  3. change MARIADB_ROOT_PASSWORD first time creation. After that it is fixed. So after generation of the containers you can (should) return it to its original or some other value
  4. set the others to what you like

With Visual Studio Code Containers Extension

  • Open compose.yaml and
  • Click Run all services
image

Without the Extension

In a termanal, start your application by running: docker compose up --build.

Setup php xdebug

  • Install xdebug extension
  • Move the folder .vscode to the root of the project. This folder contains the setup for the VSCode PHP debugger (launch.json).

in detail

The copied launch.json contains settings so that the PHP Debug extension sees root of the webserver at htdocs:

            "pathMappings": {
                "/var/www/html": "${workspaceFolder}/htdocs"
            }

Setup Webserver

Move the folder htdocs including its content to the root of the project folder.

Setup database

create database my_database;
create user 'my-user'@'%' identified by 'my-password';
grant all privileges on my_database.* to 'my-user'@'%';
flush privileges;

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors