Skip to content

Commit 53c4376

Browse files
Merge pull request #27 from php-debugger/phpstorm
write the phpstorm integration page
2 parents 4eaf6af + 8d483b0 commit 53c4376

2 files changed

Lines changed: 153 additions & 4 deletions

File tree

‎docs/integrations/phpstorm.md‎

Lines changed: 135 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,139 @@
22
title: PhpStorm
33
---
44

5-
PhpStorm has first-class DBGp support: listen for connections and debug with zero extra plugins.
5+
PhpStorm needs no plugin and no special configuration to work with PHP Debugger. It
6+
already speaks the protocol, and its defaults already match ours — it listens on
7+
port `9003`, which is where the debugger connects.
68

7-
:::note
8-
This page is a work in progress — full documentation is coming soon.
9-
:::
9+
This page follows the [User Guide](../user-guide/starting-the-debugger.md) section
10+
by section, saying what each one looks like in PhpStorm. Each links on to
11+
JetBrains' own documentation, which is the authority on the editor side.
12+
13+
## Starting the debugger
14+
15+
[Guide: Starting the Debugger](../user-guide/starting-the-debugger.md)
16+
17+
There is nothing to start. The debugger is available on every request, so the only
18+
switch is PhpStorm's: **Run | Start Listening for PHP Debug Connections**, or the
19+
telephone icon in the toolbar. Turn it on when you want to debug and off when you
20+
are finished.
21+
22+
This is what JetBrains call zero-configuration debugging, and it is the mode to
23+
use — you do not need a run configuration, a server entry, or a browser extension
24+
to trigger a session.
25+
26+
One setting worth knowing about: **Settings | PHP | Debug | Break at first line in
27+
PHP scripts**. With it on, PhpStorm stops at the first line of every request it
28+
receives. That is occasionally useful and usually not what you want, especially
29+
here, where every request arrives.
30+
31+
**JetBrains docs:** [Zero-configuration debugging](https://www.jetbrains.com/help/phpstorm/zero-configuration-debugging.html)
32+
· [Start a PHP debugging session](https://www.jetbrains.com/help/phpstorm/php-debugging-session.html)
33+
34+
## Connecting to a client
35+
36+
[Guide: Connecting to a Client](../user-guide/connecting-to-a-client.md)
37+
38+
PhpStorm's debug port lives at **Settings | PHP | Debug**, and defaults to `9003`.
39+
If you change it there, change
40+
[`php_debugger.client_port`](../reference/settings.md#php_debuggerclient_port) to
41+
match.
42+
43+
When your code runs in a container, the other half of the setup is path mapping —
44+
telling PhpStorm which local directory corresponds to the path the debugger
45+
reports. That is configured under **Settings | PHP | Servers**, and it is the usual
46+
reason breakpoints in a container are ignored.
47+
48+
Over HTTP that is all you need — PhpStorm matches the connection to a server entry
49+
by the URL that was requested. On the command line there is no URL to match on, so
50+
you have to say which entry applies. Set `PHP_IDE_CONFIG` in the environment the
51+
script runs in, naming the server exactly as it is named in that dialog:
52+
53+
```bash
54+
PHP_IDE_CONFIG="serverName=myapp"
55+
```
56+
57+
Leaving it out, or misspelling the name, looks exactly like a mapping problem: the
58+
session connects and the breakpoints are ignored. The
59+
[Docker](../getting-started/docker.mdx) page sets it alongside the debugger's own
60+
settings.
61+
62+
**JetBrains docs:** [Configure Xdebug](https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html)
63+
64+
## Breakpoints
65+
66+
[Guide: Breakpoints](../user-guide/breakpoints.md)
67+
68+
Click the gutter beside a line to set one. Right-click it for a condition or a hit
69+
count, and use **Run | View Breakpoints** for the full list, including exception
70+
breakpoints and breakpoints on a function by name.
71+
72+
PhpStorm's **Mute Breakpoints** button disables them all at once without deleting
73+
them. It is handy mid-session, but muted breakpoints are still breakpoints as far as
74+
the debugger is concerned — for the overhead to go away they have to be removed.
75+
76+
**JetBrains docs:** [Breakpoints](https://www.jetbrains.com/help/phpstorm/using-breakpoints.html)
77+
78+
## Step debugging
79+
80+
[Guide: Step Debugging](../user-guide/step-debugging.md)
81+
82+
The Debug tool window has the four actions the guide describes — Step Into, Step
83+
Over, Step Out and Resume — plus **Run to Cursor**, which PhpStorm implements as a
84+
temporary breakpoint just as the guide explains.
85+
86+
When a step seems to skip past something, the cause is usually PhpStorm rather than
87+
the debugger. Two settings pages decide what it steps into: **Debugger | Stepping**,
88+
which can skip library scripts and any scripts you list, and **PHP | Debug | Step
89+
Filters**, which can skip magic methods, constructors and named methods. **Force
90+
Step Into** ignores both for a single step.
91+
92+
**JetBrains docs:** [Step through the program](https://www.jetbrains.com/help/phpstorm/stepping-through-the-program.html)
93+
94+
## Inspect variables
95+
96+
[Guide: Inspect Variables](../user-guide/inspect-variables.md)
97+
98+
The Debug tool window shows the call stack on one side and variables on the other.
99+
Selecting a frame in the stack repoints the variables pane at that frame, which is
100+
the part worth getting into the habit of using.
101+
102+
PhpStorm also shows values inline, greyed out beside the code itself, which often
103+
saves going to the panel at all.
104+
105+
**JetBrains docs:** [Examine a suspended program](https://www.jetbrains.com/help/phpstorm/examining-suspended-program.html)
106+
107+
## Watches and edits
108+
109+
[Guide: Watches and Edits](../user-guide/watches-and-edits.md)
110+
111+
Watches live in their own pane in the Debug tool window, and **Evaluate Expression**
112+
handles the one-off case. Both run real PHP in the paused request, so the guide's
113+
warnings about side effects apply exactly as written.
114+
115+
To change a value, double-click it in the variables pane, or use **Set Value** from
116+
its context menu.
117+
118+
**JetBrains docs:** [Evaluate expressions](https://www.jetbrains.com/help/phpstorm/evaluating-expressions.html)
119+
120+
## Logging
121+
122+
[Guide: Logging](../user-guide/logging.md)
123+
124+
The Console tab of the Debug tool window carries your script's output, and PHP's
125+
warnings and notices appear there as the request produces them. Nothing needs
126+
enabling on our side; PhpStorm asks for both when the session opens.
127+
128+
**JetBrains docs:** [Debug tool window: Console](https://www.jetbrains.com/help/phpstorm/debug-tool-window-console.html)
129+
130+
## Troubleshooting
131+
132+
[Guide: Troubleshooting](../user-guide/troubleshooting.md)
133+
134+
If a session never arrives, check the two things that are PhpStorm's rather than
135+
ours: that it is actually listening, and that path mappings are right for where the
136+
code runs. Our [troubleshooting page](../user-guide/troubleshooting.md) covers the
137+
debugger side, and the debug log at the default level will tell you whether a
138+
connection was attempted and where to.
139+
140+
**JetBrains docs:** [Troubleshooting PHP debugging](https://www.jetbrains.com/help/phpstorm/troubleshooting-php-debugging.html)

‎src/css/custom.css‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,21 @@ article a {
197197
.theme-admonition-info [class*='admonitionIcon'] svg {
198198
fill: var(--ifm-color-primary);
199199
}
200+
201+
/* Mark links that leave the site. Internal links are written relative, so the
202+
protocol prefix is a reliable test. The marker sits inside the link so it
203+
inherits colour and underline, and is hidden from assistive technology --
204+
screen readers announce the destination from the href already. */
205+
.markdown a[href^='http']::after {
206+
content: '\2197';
207+
display: inline-block;
208+
margin-left: 0.25em;
209+
padding: 0 0.25em;
210+
border: 1px solid currentColor;
211+
border-radius: 0.25em;
212+
font-size: 0.7em;
213+
font-weight: 700;
214+
line-height: 1.5;
215+
vertical-align: 0.15em;
216+
opacity: 0.75;
217+
}

0 commit comments

Comments
 (0)