This is automatically handled by the /etc/hosts
entry that is being created by the omeka-s/docker-entrypoint.sh
file. Example:
echo "$(ip route|awk '/default/ { print $3 }') dockerhost.local" >> /etc/hosts
This is all automatically handled by the code in omeka-s/Dockerfile
and results in the following outcome:
- Xdebug extension for PHP installed. Note: to reproduce this in a non-Dockerized environment, you could use
sudo apt-get install php8.2-xdebug
- Xdebug configured for remote debugging. Please note that some settings have been renamed since Xdebug version 3. The settings below are the ones for Xdebug 3. Contents of the config file
/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
:
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.start_with_request = yes
xdebug.client_host = dockerhost.local
xdebug.log = /tmp/xdebug.log
The instructions below are written for a specific module development use case where the module's the source code has been volume-binded from a folder on host (./externals/Omeka-S-module-Ark
) to the docker container (/var/www/html/modules/Ark
). Remote debugging also works in other use cases, although you might need to setup some things differently.
- Git-clone the module's source code to your host file system. Here:
./externals/Omeka-S-module-Ark
- Open PhpStorm
- Open the directory with the module's source code. Here:
./externals/Omeka-S-module-Ark
. Do not! create a 'New project from Existing Files...` - Open Settings (Ctrl + Alt + S)
- Click on PHP in the menu
- Choose a CLI interpreter.
- Click the
...
button - Click
+
and choose From Docker, Vagrant, ... (etc) - Select the Docker radio button
- Choose server (usually the default 'Docker' socket)
- Choose image name: 'omekas-docker-omekas:latest'
- Choose PHP interpreter path: 'php'
- The CLI interpreter is now added. It should detect and display the PHP (here: 8.2.11) and Xdebug (here: 3.3.1) versions.
- Click OK to save and exit this screen.
- Click the
- Click on the Open folder icon next to Docker container:
- Edit the volume binding using the pencil icon.
- Host path: (keep the default)
- Container path: /var/www/html/modules/Ark
- Click OK to save and exit this screen.
- Confirm that the value at Path mappings is now correct. This has been set by the previous step.
- Expand the PHP menu option
- Click on PHP -> Debug
- Usually, the default settings are sufficient. If not, then one can change it here.
- Click OK to save.
- Click on PHP -> Server to set the location of the web server
- Click
+
to create a new server configuration and enter the values - Name: Omeka S Docker (or something else, does not really matter)
- Host: omeka.local
- Port: 80
- Debugger: Xdebug
- Check the box for 'Use path mappings... (etc)'
- At the first "subfolder" of "Project files" -> Absolute path on the server: /var/www/html/modules/Ark
- Click
- Expand the Build, Execution, Deployment menu option and click on Deployment
- Confirm that these settings are correct:
- Type: Local or mounted older
- Folder: (path/to/...)/externals/Omeka-S-module-Ark
- Web server URL: http://omeka.local
- Click OK to close Settings
- Create a debug configuration
- Click the Run dropdown and choose Edit configurations
- Click
+
and choose PHP remote debug - give it a name and keep all default settings
- Click OK to save and exit these settings.
- Press the debug icon or the phone icon to start listening for incoming Xdebug connections.
- Open PhpStorm and start listening for incoming debug connections.
- Exec into the Docker container
docker exec -it omekas bash
- Install telnet
apt-get update && apt-get install telnet -y
- Use telnet to verify connectivity
telnet host.docker.internal 9003
Install the Xdebug helper
extension.
- for Firefox: https://addons.mozilla.org/nl/firefox/addon/xdebug-helper-for-firefox/
- for Chrome: https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc
- Open your browser
- Go to http://omeka.local
- Activate the Xdebug plugin
- Set a breakpoint in the code using PhpStorm
- Use the browser to go to the page where the breakpoint is set
- Switch from browser to PhpStorm. Press F9 to resume the program (actually this jumps to the first breakpoint). Then press F8 to step through the debugger.