XAMP apache+mysql+php+phpmyadmin v dockerovi

Web server stack

Information

PHP:

  • ver. 8.2.8
  • modules: pdo, pdo_mysqlm, mysqli, zip, intl, gd (xdebug - only in dev build)

Apache

MariaDb:

  • host: db (port 3307)
  • local IP: 172.28.0.11 (port 3306)
  • root access: root/LocalData
  • user access: data/localdata

phpmyadmin:

  • IP address (external - host): localhost:9091

tools:

  • Only for dev environment: The web container contains tool composer. Just login to web container (make attach) and type composer.

Installation

  • Go to directory xamp/docker_web
  • Rename file .env.default to .env or .env.prod (for production development)
  • Mofify desired parameters in .env file

Linux

  • in bash, run: make dev

Windows

  • in command line, run file make_dev_win.bat

Configuration

All configuration directives are in .env or .env.dist files:

  • WEB_PORT - IP port for apache service
  • WEB_PORT_SSL - IP port for apache service (https)
  • DB_PORT - IP port for database service
  • DBM_PORT - IP port for phpMyAdmin application
  • DB_DATABASE - local default database
  • IP_NETWORK - docker network range (e.g. 172.18.0.0/16)
  • IP_WWW - docker IP of apache (e.g. 172.18.0.10)
  • IP_DB - docker IP of MariaDB server (e.g. 172.18.0.11)
  • IP_PHPMYADMIN - docker IP of phpMyAdmin app (e.g. 172.18.0.12)

Detailed description

How to run XAMP solution

  • open terminal in xamp/docker_web
  • to run server, type:
    • {linux} make dev
    • {windows} win_make_dev.bat
  • checkt url localhost:9090 in web browser
    • XAMP web root is: xamp/www

List of all control/configuration commands:

In xamp/docker_web directory is prepared Makefile with these actions:

  • make install - install codesniffer, lint and phpstan tools. These tools is needed to checking code quality (commands cs,lint,phpstan)
  • make dev - run XAMP stack in development configuration: apache, mysql, phpmyadmin
  • make prod - run XAMP stack in production configuration: apache, mysql. Debug is disabled
  • make stop - stop XAMP stack (stop docker instances)
  • make import-db - import prepared SQL file into internal database. This command try to import all sql files in xamp/docker_web/dump direcory
  • make attach - run bash in docker_www container in interactive mode
  • code quality tools. These commands are used inside docker container.
    • cs, lint, cs-stats, csf, phpstan. Usage of these commands are described bellow.

Universal makefile approach:

  • login into docker container: make attach
  • inside container run:
    • make phpstan project=<projectName> level=<level> - run phpstan analysis in specified project and level of checking
    • make cs project=<projectName> - run codesniffer for selected project
    • make cs-stats project=<projectName> - run codesniffer for selected project with simple summary
    • make csf project=<projectName> run codesniffer automatic error fixer

Note, that in <projectName> folder have to exists phpstan.neon and ruleset.xml

Debugging using xdebug

With xdebug module is poosible debug php code running inside in docker. Xdebug is enabled by default, but the browser extension is needed:

You need IDE with xdebug support PhpStorm

  • Open File/Settings
  • select PHP / Debug : check XDebug part - Debug port: 9000,9003; Can accept external connections:yes
  • select PHP / Servers : add new server
  • Name: custom name e.g. "localDocker"
  • Host: IP addres or name of your PC (localhost)
  • Port: 9090
  • Debuger: XDebug
  • In the bottom list, in the right column 'Absolute path on the server' put value '/var/www/html/PROJECT', where in left column is selected path in part 'Project files'. Note, PROJECT mean name of directory directory with your project.

Xdebug setting

How to disable xdebug:

  • open hidden file xamp/docker_www/.env
  • replace row XDEBUG_MODE=debug by XDEBUG_MODE=off
  • in xamp/docker_web run commands:
    • make stop
    • make dev
Contributors 1
Juraj Ďuďák 100.0%
Languages
  • Makefile [94.29%]
  • Batchfile [3.98%]
  • Shell [10.49%]
  • php
  • PHP [1.73%]
  • Relations
    apollo
    depended
    Created at 31.01.2021
    Last update 13.01.2025, 22:33:32