> For the complete documentation index, see [llms.txt](https://docs.mikopbx.com/mikopbx-development/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mikopbx.com/mikopbx-development/module-developement/debuging/debug-php-script.md).

# Debug PHP Script

MikoPBX ships the Xdebug 3 extension (`xdebug.so`) but keeps it switched off: the file `/etc/php.d/15-xdebug.ini.disabled` is not loaded by PHP. The `pbx-console xdebug` commands create a real `/etc/php.d/15-xdebug.ini` for you, so you never have to edit the PHP configuration by hand.

To enable debugging of CLI PHP scripts:

```
pbx-console xdebug enable-cli 192.168.0.12
```

For debugging PHP scripts of the web interface (admin cabinet and REST API):

```
pbx-console xdebug enable-www 192.168.0.12
```

* **192.168.0.12** — IP address of the PC from which debugging is performed. PhpStorm must be running on that PC and listening for incoming connections.
* The generated configuration uses **`xdebug.client_port=9003`** — the Xdebug 3 default. Set the same port in PhpStorm.
* `xdebug.start_with_request=yes` is written, so **every** request starts a debug session. No browser extension and no `XDEBUG_SESSION` cookie are required.
* `enable-www` restarts `php-fpm` to pick up the new configuration; the web interface is unavailable for a few seconds.

Re-running the command with a different IP address only rewrites the `xdebug.client_host` line. To switch debugging off again, delete `/etc/php.d/15-xdebug.ini` and restart `php-fpm` (`monit restart php-fpm`).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.mikopbx.com/mikopbx-development/module-developement/debuging/debug-php-script.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
