Web server stack
Information
PHP:
- ver. 8.2.8
- modules: pdo, pdo_mysqlm, mysqli, zip, intl, gd (xdebug - only in dev build)
Apache
- web root: www
- IP address (external - host):
- http://localhost:9090
- https://localhost:9043 (self signed certificate)
- IP address (local - docker):
- http://172.28.0.10 (port 80)
- https://172.28.0.10 (port 443)
- Apache run under local user (UID=1000). For running as second user (UID=1001) look in Dockerfile-dev/Dockerfile-prod - line 5 and line 36
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 typecomposer
.
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
- {linux}
- checkt url
localhost:9090
in web browser- XAMP web root is:
xamp/www
- XAMP web root is:
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, phpmyadminmake prod
- run XAMP stack in production configuration: apache, mysql. Debug is disabledmake 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 inxamp/docker_web/dump
direcorymake 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 checkingmake cs project=<projectName>
- run codesniffer for selected projectmake cs-stats project=<projectName>
- run codesniffer for selected project with simple summarymake 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:
- Firefox: Xdebug Helper for Firefox (https://addons.mozilla.org/en-US/firefox/addon/xdebug-helper-for-firefox/)
- Chrome: Xdebug Helper (https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc?hl=en) After installig extension, enable debug requests in address bar.
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.
How to disable xdebug:
- open hidden file
xamp/docker_www/.env
- replace row
XDEBUG_MODE=debug
byXDEBUG_MODE=off
- in
xamp/docker_web
run commands:make stop
make dev