# Configuring XDebug

{% embed url="<https://youtu.be/vCcT7TPv8lA>" %}
Xdebug setup
{% endembed %}

## Setup

php with xdebug is can be set for local, by changing $PROJECT\_IMAGE variable to `xdebug` in corresponding `.env` files, ensuring corrent docker image to be used.

## Debugger settings in PhpStorm IDE

Now to set the PhpStorm, go to:

*Preferences > Languages & Frameworks > PHP > Debug*

In this window check the following settings:

* Xdebug section, set port 9111
* “Can accept external connections” is checked
* “Ignore external connections through unregistered server configurations” is checked
* Other settings is up to your preferences of the debugger

Now we need to set up a server configuration, to map local files to remote application container, head to:

\_Languages & Frameworks > PHP > Debug > Servers\_\_

* Add new configuration by clicking the **+** symbol
* Host:
* Port: 3001, which is default nginx port, try to avoid using varnish port and disable varnish in magento configuration during debug sessions
* Debugger: Xdebug
* And map your local `./src/` directory to remote `/var/www/public`

## Setting up IP alias

To allow connections from container to debug console in PhpStorm you need to add following alias to you system, this setting is **not** persisted between restarts, update your env accordingly

### **Linux**

`sudo ip address add 172.254.254.254/24 dev docker0`

### **macOS**

`sudo ifconfig en0 alias 172.254.254.254 255.255.255.0`

Now the configuration is complete, happy debugging!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://scandipwa.gitbook.io/docs/how-to-tutorials-intermediate/configuring-xdebug.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
