3

How to setup and use Xdebug in Magento 2 which is very necessary tool for Magento 2.

1

1 Answer 1

6

I have setup Xdebug for PHPSTORM in Linux system these are the steps.

Step 1 :-

sudo apt-get install php-xdebug

Xdebug installation is up to you and after that please insure Xdebug is installed .

enter image description here

Step 2 :-

Now we need to add some setting in our php.ini file so first you need to check from where your configuration is being loaded.

enter image description here

Go to configuration loaded file.

/etc/php/7.1/apache2/php.ini

Add this setting last at you php.ini file

zend_extension="/usr/lib/php/20151012/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port = 9000
xdebug.remote_autostart = 0
xdebug.profiler_enable = 0
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = req
xdebug.remote_connect_back = 1
xdebug.remote_log="/var/log/xdebug/xdebug.log"
xdebug.idekey=PHPSTORM

This is screen-cast of your file will be look like this.

enter image description here

Step 3:- PHPSTORM

Start Your PHPSTORM GO To File >> Settings

enter image description here

Make sure your xdebug.remote_port = 9000 and in your PHPSTORM setting Debug Port == 9000 must be the same.

Step :- 4 [ Setting are completed ! ]

Now Go to your PHPSTORM in Menu >> Run >> Start Listing For Php Debug Connection

Start this setting before launching your project url in your browser.

Screen- Cast

enter image description here

Now open you browser and start your project and add session key to your url so that phpstorm inform to start debugging.

http://localhost/magento223?XDEBUG_SESSION_START=18200
?XDEBUG_SESSION_START=18200  == This is phpstorm session key.

That's all to configure Xdebug in PHPSTORM do let me know if you face any issues.

3
  • How to you get session key?
    – xanka
    Sep 21, 2019 at 14:41
  • @xanka just add ?XDEBUG_SESSION_START=18200 after your url Sep 21, 2019 at 18:57
  • after the 2nd step, we may need to restart apache: sudo systemctl restart apache2 Jul 20, 2022 at 10:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.