Login to Database
docker compose exec postgres psql -U serve-opg
Clear Cache
docker compose exec app rm -rf /var/www/var/cache /tmp/app-cache
To enable Xdebug running via Docker in PHPStorm you will need to:
- In
Preferences > Build, Execution, Deployment > Docker
selectDocker for Mac
- In
Preferences > Languages and Frameworks > PHP
Click the...
button next toCLI Interpreter
- Click the
+
button to add a new CLI and selectFrom Docker, Vagrant, VM, Remote
- Select
Docker Compose
, forServer
chooseDocker
and selectapp
for Service. ClickOK
andApply
. - Click
Run > Edit Configurations
from the top menu bar, then+
and selectPhpUnit
- Name this configuration
Docker
, underTest Scope
selectDirectory
addtests
directory as the filepath. ClickOK
. - In
Preferences > Language & Frameworks > PHP > Debug
underXdebug > Debug port
enter10000
. HitApply
andOK
.
As Xdebug has a large performance hit, it is not installed as part of the Dockerfile by default. Instead it is set as a build argument in docker-compose.local.yml to ensure it will only ever be enabled for local dev. To build the app image with xdebug enabled, run:
docker compose -f docker-compose.local.yml -f docker-compose.yml up -d --build --remove-orphans loadbalancer
or
make up-dev
Now you can add break points to any line of code by clicking in the gutter next to line numbers. Then you can either run the entire test suite by selecting DOCKER
from the dropdown next to the test buttons in the top right of the page and click the phone icon so it turns green. Hit the debug button to run the suite.
Alternatively you can run individual tests by hitting the debug button next to the test method name in the test class. Once the code gets to a break point you can step through and run executions on the current state of the app to help with debugging.