I want to use the debugger to debug my module but I don't know how to configure and set up debugger in phpstorm, any hints or solutions?
3 Answers
Follow this step to configure xdebug.
1:Run this command in terminal
sudo apt install php7.4-xdebug
after that check PHP version by this command and we will configure according to that xdebug version
PHP -v
in my case, Xdebug version is given v3 so that I will set it up accordingly
2: now run this command
sudo nano /etc/php/7.4/mods-available/xdebug.ini
and paste the following code in that file
zend_extension=/usr/lib/php/20190902/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.client_host = 127.0.0.1
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.client_port = 9003
xdebug.mode = debug
and remember in the first line /usr/lib/php/"your folder name"/xdebug.so go this path and check what the folder number is and paste it according to in some cases it is different but mostly it is the same.
Here are the settings if your Xdebug version is v2
zend_extension=/usr/lib/php/20190902/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9003
now restart apache
sudo systemctl restart apache2
so far half our work is done now let's do some settings in phpstorm open PHPstorm got to File>>Settings>>PHP>Xdebug and click on the validate a new window will open and in that window type your URL accordingly and hit Validate
so far your Xdebug is configured in phpstorm, and you can use breakpoint and turn on debug listener and hit that file and start using xdebug in case any issues let me know, Thanks in advance
You have to follow these steps :
Install X debug for the PHP version which you are using by this command :
sudo apt install php7.4-xdebug
In this file add these lines :
zend_extension=/usr/lib/php/20190902/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.client_host = 127.0.0.1
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.client_port = 9003
xdebug.mode = debug
Then install x debug extension from the google chrome.
Finally change the x debug port in the PHP storm in this way :
File>>Settings>>PHP>Xdebug
If you find any more problem then tell me we will resolve that also.
Thanks!
Sometimes When you try to validate it gives some error like invalid port or service not available etc always make sure the port you set in that file and the port in your phpstorm is same, like in my case it is 90003 and always restart apache and if your xdebug is validated but still not working then try to use a Xdebug Helper extension
thats all, thanks