Trigger an Xdebug breakpoint for CLI commands in PhpStorm with Docker
Learn how to configure Xdebug to pause CLI command execution at breakpoints in PhpStorm.
Lesson Content
The Magento web entry point is pub/index.php. When Nginx receives a web request, it routes the request to this file, which starts the Magento application.
Open pub/index.php in PhpStorm and find the $bootstrap variable. Click in the gutter beside the line where it is used to set a breakpoint.
When the request reaches this line, Xdebug pauses execution and hands control to PhpStorm.
Start the Xdebug listener from Run -> Debug magento.test. Use the name of your site if it is different. Open the Debugger tab at the bottom of PhpStorm and verify that it shows Waiting for incoming connection with IDE key PHPSTORM.
Next, return to your browser and make sure the Xdebug browser plugin is enabled. Its icon should be green. Refresh the page.
When Magento reaches the breakpoint, PhpStorm comes to the foreground and pauses the request. You can inspect the variables available through Xdebug, including cookies, environment variables, and request data.
You can add additional breakpoints by clicking in the gutter beside other lines. Use the play button to resume execution and continue the request. If there are no more breakpoints, Magento finishes processing and returns the response to your browser.
Join the discussion!
Comments
Want to comment on this lesson?
Log in to leave comments.