Use Xdebug in Local with PhpStorm

Local supports Xdebug in PhpStorm by default using zero-configuration debugging.

You do not need to modify php.ini files or install browser extensions and Local add-ons.

Before you start

⚠️ Remove the old Xdebug + PhpStorm add-on if you see it under “Installed Add-ons”. It is no longer needed to use Xdebug with Local and PhpStorm.

Set up PhpStorm for your Local site

For each Local site that you want to use with Xdebug and PhpStorm:

1. Local: Enable Xdebug in the site overview

Xdebug is disabled by default because it can make pages load more slowly. Change the Xdebug toggle from “Off” to “On” in your site overview when you want to use Xdebug. Your site will restart if running. Start your site if it’s not running after you turn Xdebug on.

2. PhpStorm: open your site’s ‘app/public’ directory

Click “Site Folder” in Local, open the “app” folder in your file explorer, then open the “public” folder in PhpStorm. Click “Trust Project” if prompted. It’s important to open the public directory, not the app or other directories, so that Xdebug is able to map your files more easily.

3. PhpStorm: turn off “force break” in PHP debug settings

4. PhpStorm: Open a PHP file and set a breakpoint

5. PhpStorm: Listen for debug connections

Choose RunStart Listening for PHP Debug Connections, or click the larger “Bug” icon at the top of the PhpStorm toolbar.

6. PhpStorm: Accept incoming connection from Xdebug

Visit the site in your web browser, for example by clicking “Open Site” in Local.

PhpStorm will show an “Incoming Connection From Xdebug” dialog.

Click the public folder in the “select a project” area, then click Accept.

Inspect your running program

PhpStorm will now freeze execution at your breakpoint. You can step through your code with the controls in PhpStorm’s Debug panel. Learn more about inspecting a running program from JetBrains docs.

In short, you can use the “Threads and Variables” pane to see the value of variables in scope, use “step over”, “step into” and “step through” controls to step through your code, or continue execution to the next breakpoint or the end of your code with “resume program”:

How to stop Xdebug

To stop the debugging session, click the stop button in the debug pane pictured above.

To prevent future sessions from starting, choose Run → “Stop Listening for PHP Debug Connections” in PhpStorm or click the larger bug icon in PhpStorm’s header bar again.

You can also disable Xdebug in Local to stop PhpStorm from freezing execution at breakpoints. When you are not using Xdebug, we recommend leaving it off in Local for improved performance:

Future debugging sessions

Future connections for this site will work automatically and pause execution at breakpoints you set, as long as PhpStorm is set to listen for connections and Xdebug is on in Local. You do not need to run through the above setup every time.

If you want to change your configuration or force the “Incoming Connection” dialog to appear again, delete the PHPServers entry in PhpStorm preferences. Then enable Xdebug in Local, listen for debugging connections in PhpStorm, and set a breakpoint. Refresh your browser to present the “Incoming Connection” prompt again.

Troubleshooting

No “Incoming Connection from Xdebug” in PhpStorm when refreshing your browser

Execution is not frozen at the breakpoint when refreshing your browser

Xdebug browser extension has no effect

You do not need browser extensions like the one pictured below to use Xdebug with Local.

Local sets start_with_request=yes, so all requests will automatically use Xdebug if it’s on in Local and PhpStorm is listening for connections.

No Xdebug option in Local