To use debug with the docker-compose
development environment, some extra steps are required.
If you have never added a configuration to PHPStorm, click on the Add configuration...
button on the top-right of the main window:
If you have already added a configuration, click on the configurations drop-down and click on Edit configurations...
.
In the window that opens, click on the +
button at the top-left and then select PHP Web Page
from the drop-down:
In the right pane, choose a name for the configuration (the name is not important), then click on the ...
to the right of the Server
field under the Configuration
section:
In the window that opens, click on the +
button at the top-left of the page:
Then on the right pane, give a name to the server (the name is no important) and configure the host as follows:
- Host:
127.0.0.1
- Port:
8080
- Debugger:
Xdebug
Then tick the Use path mappings
box and add the following mappings:
- bin:
/var/www/html/bin
- public:
/var/www/html/public
- src:
/var/www/html/src
- tests:
/var/www/html/tests
Mappings can be added by finding the correct folder in the folder tree and double-clicking on the right half of the bottom pane next to the entry for the desired folder:
Click OK in the server configuration button. back to the Web Page configuration, select the browser you want to use to develop under the Browser
dropdown in the Configuration section and then click OK:
If you haven't done so yet, start the development environment with
make up
(ordocker-compose up -d
) prior to executing this step.
In the top-right corner of the window, click on Start Listening for PHP Debug Connections
:
Put a breakpoint in a place you are sure it's going to hit (public/index.php
is a perfect candidate) and put a breakpoint on a random line of code:
Press on the Debug
button:
If everything went according to plan, a browser tab should open and the breakpoint trigger, presenting you with the debug view: