Video Lesson: Trigger an Xdebug breakpoint in PhpStorm with Docker

Trigger an Xdebug breakpoint in PhpStorm with Docker

Learn how to use Xdebug breakpoints to pause and inspect PHP execution in PhpStorm.


Lesson Content

Magento’s web entry point is the index.php file in the pub directory. Nginx directs incoming requests to this file, which starts the Magento application.

Open pub/index.php in PhpStorm and find the line that assigns the $bootstrap variable. Click in the gutter beside that line to set a breakpoint.

When a request reaches this line, PhpStorm pauses execution and Xdebug gives you control of the request.

Start the Xdebug listener from Run -> Debug magento.test, replacing magento.test with the name of your site. Open the Debugger tab at the bottom of PhpStorm and confirm that it says Waiting for incoming connection with IDE key PHPSTORM.

Next, return to your browser and make sure the Xdebug browser extension is enabled. The extension icon should be green. Refresh the page to send a request to Magento.

When execution reaches the breakpoint, PhpStorm comes to the foreground. You can inspect the variables available to Xdebug, including cookies, environment variables, and request variables.

You can set multiple breakpoints by clicking in the gutter beside additional lines. When PhpStorm pauses at a breakpoint, click the play icon to resume the request. Execution continues until it reaches another breakpoint.

Because there are no more breakpoints in this example, PhpStorm resumes the request and the response is returned to the browser, allowing the page to finish loading.

Maggie

Hey, I'm Maggie! 👋

Ask me anything.

Want to chat with Maggie?

Log in for AI tutor access.

Comments

Join the discussion!

Notes

Keep track of what you learn!