How do I install and configure Xdebug/PhpStorm - php

I'm trying to install Xdebug and PhpStorm as per the following:
I have an iMac that I work form where I just write the PHP scripts.
I have an Ubuntu 14.04 Server which runs the PHP scripts that I upload to it.
I want to install Xdebug on the Ubuntu Server machine but still use my iMac for writing the scripts, I want to be able to debug my code with Xdebug/PhpStorm from my iMac on my Ubuntu Server.
I have followed several guides and have installed Xdebug properly, sudo apt-get install php5-xdebug. I have also edited the php.ini file so that the following text appears in my phpinfo file: "with Xdebug v2.2.3". I added the following lines to my php.ini file:
zend_extension=/usr/lib/php5/20121212/xdebug.so
xdebug.default_enable=1
xdebug.idekey=PHPSTORM
xdebug.remote_enable=1
xdebug.remote_autostart=0
xdebug.remote_port=9000
xdebug.remote_connect_back=1
Then I installed PhpStorm 2017.2 on my iMac. But from here I can't get anything to work.
How do I configure PhpStorm to be able to debug the code that's on my Ubuntu Server? I have SSH on my Ubuntu Server and can connect to my Ubuntu Server with SSH.

Related

Use Xdebug with PhpStorm and WSL

I use WSL (Ubuntu 16.14) from Windows 10 as a web server with PHP 7.1 fpm and Apache.
I want to use Xdebug from PhpStorm 2018 with WSL but it's not working well.
Xdebug is installed on my Ubuntu server and it works well, I see it on phpinfo() output.
Here the php.ini config for Xdebug:
[Xdebug]
zend_extension="/usr/lib/php/20170718/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back=On
xdebug.remote_host=127.0.0.1
xdebug.remote_port = 9001
xdebug.idekey = PHPSTORM
I configured the port in php storm as 9001 too.
The problem is more on the connection between PhpStorm and WSL. I try it with the remote way. In the Run > Edit config popup, I use PHP Web Page and when I use the Validate tools, all is OK except the remote host.
I set it to 127.0.0.1 and this is the point.
When I listen the debugging tools, it said : Port 9001 is busy
How can I do a link between localhost and localhost ?
I am using WSL (Ubuntu 20.04 LTS) from Windows 10 as a web server with PHP 7.4 fpm and Apache with Xdebug Version 3.0.4
Following are the steps followed to configure the Xdebugger in the PHPSTORM and it works for me :
Install the Xdebug
select wsl in cli interpretor
To get the client_host run the ifconfig in ubuntu or ipconfig in bash
Open the below file
sudo vi /etc/php/7.4/cli/conf.d/20-xdebug.ini
add below in the above file
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.client_host=[ip4 address/Client_host]
xdebug.remote_connect_back=On
xdebug.client_port="9003"
xdebug.remote_handler=dbgp
xdebug.start_with_request=yes
xdebug.remote_log=/tmp/xdebug.log
Then use the Xdebugger chrome extension (xdebugger helper)
Restart the apache server.
Add the breakpoint to the file and refresh the page

Debug php with Xdebug on mac OS HighSierra

I used https://xdebug.org/wizard.php to check my Xdebug status that I installed using below instruction.
But it's seems not working. I tried with NetBeans Xdebug / Sublime Xdebug Clinets and also PHPStrome, but php files are not hit the debug point.
When I check the php content with I used https://xdebug.org/wizard.php it's also displayed
Xdebug installed : no
Bu I have successfully run all commands and copied the file into xammp's extentions folder.
php.ini conetnt:
;zend_extension=opcache.so
zend_extension="/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so"
[xdebug]
xdebug.remote_host=localhost
xdebug.remote_port=9001
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.idekey="netbeans-xdebug"
xdebug.remote_log="/Applications/XAMPP/logs/xdebug.log"
Tried list:
I have tried this one Xdebug on macOS 10.13 with PHP 7 but it's not work for me.
For #streos (I tried to install xdebug via brew but it's won't work for me):
Had problem with permissions, the system didn't let my install xdebug, so I ended up installing another php instead of using the built-in one:
Try this article

Xdebug with PHP7 running on a remote EC2 instance on a Docker container with nginx

I'm trying to setup Xdebug to help our development cycle but I'm having some difficulty getting it working. I've also never used Xdebug before so maybe I'm misunderstanding how it works.
We're using PHP7 running on Docker containers with nginx in front of it. These Docker containers are hosted on a private VPC on EC2 servers.
I've installed xdebug-2.5.4 through my dockerfile
RUN wget http://xdebug.org/files/xdebug-2.5.4.tgz && tar -xvzf xdebug-
2.5.4.tgz
WORKDIR xdebug-2.5.4
RUN phpize
RUN ./configure
RUN make && cp modules/xdebug.so /usr/lib64/php/modules
I've confirmed that it's installed by checking my installed php modules (php -m)
I've modified my PHP.ini:
[xdebug]
zend_extension = /usr/lib64/php/modules/xdebug.so
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
xdebug.remote_host="<ip address of machine running docker>"
xdebug.remote_port=9000
xdebug.remote_mode=req
xdebug.remote_log="/tmp/xdebug.log"
I've modified my PhpStorm preferences with the host as the same IP address and port in xdebug.remote_host and xdebug.remote_port.
However, I'm at a loss as to where to continue from here. It's worth noting that this isn't running a PHP Web Server, but more of a RESTFUL API that we test using Postman. Is it even possible to use xdebug with such a workflow?

Problems installing xdebug.so extension on local AMP environment

Edit: I've now removed the version of xdebug.so I installed manually, and installed XDebug via Homebrew. When I type "php -i" at the command line, xdebug appears to be installed; but when I run phpinfo(), there's still no sign of XDebug.
I've just got a new Mac so, like every time I buy a new Mac, I have rebuilt my local web development environment (this time, following an amazing tutorial: https://echo.co/blog/os-x-1010-yosemite-local-development-environment-apache-php-and-mysql-homebrew)
Everything has gone smoothly until I got to installing the XDebug extension. I use Komodo as a development environment so, as I've always done in the past, I followed the instructions here: http://docs.activestate.com/komodo/7.1/debugphp.html#debugphp_top
I followed the instructions to the letter, but I can't get xdebug.so to appear in my phpinfo.php() page. Here's what I did:
Created a phpinfo.php file so that I can find the correct php.ini file
Checked that phpinfo.php file and found that the "Loaded Configuration File" is "/usr/local/etc/php/5.6/php.ini"
Edited that php.ini, adding the following lines to the bottom of the file:
_
zend_extension=/usr/local/Cellar/php56/5.6.14/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.idekey=<idekey>
; You may also want this - to always start a remote debugging connection.
;xdebug.remote_autostart=1
Ran "brew services restart httpd22" (and, just to be sure, "sudo apachectl restart")
When I go reload phpinfo.php, it contains to reference to xdebug.so.
I can confirm that xdebug.so is present at /usr/local/Cellar/php56/5.6.14/lib/php/extensions/no-debug-non-zts-20131226 and that /usr/local/Cellar/php56/5.6.14/lib/php/extensions/no-debug-non-zts-20131226 is set as the "extension_dir" in php.ini.
What am I missing?!
Ultimately this proved be to be caused my me doing things in the wrong order. I'd used Homebrew to install Apache and PHP, but I'd installed Apache 2nd: this meant that it wasn't set up to work with the version of PHP I then installed.
I reinstalled PHP using the command brew reinstall php54 --homebrew-apxs, and that ensured that Apache and PHP were talking to each other.
Then, to install xdebug, I ran brew install homebrew/php/php56-xdebug. After restarting Apache, XDebug showed up in phpinfo() straight away!
Then I had to get XDebug talking to Komodo. To do this I added in the config lines from my original post to the specific xdebug config file that had been created during the Homebrew install (mine was located at /usr/local/etc/php/5.6/conf.d/ext-xdebug.ini), and then made sure that Komodo was listening on the correct port (9000 didn't work, so I changed to 9001).

Install XDebug and load in Acquia Drupal Stack?

I am trying to follow this article:
http://robshouse.net/article/xdebug-komodo-and-acquia-drupal-stack-installer
I did all of that, yet XDebug is still not being loaded or shown on phpinfo.
Has anyone got this to successfully work?
I installed XDebug with Homebrews, brew install xdebug. I copied xdebug.so to my acquia stack folder, /php/ext/xdebug.so and added the approrpiate lines to php.ini, restarted the stack and Apache and no luck.
Tried a few different articles and have not had success.
My php.ini:
[debug]
; Remote settings
zend_extension=/Applications/acquia-drupal/php/ext/xdebug.so
xdebug.remote_autostart=off
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
This is reported in my apache errors:
Failed loading /Applications/acquia-drupal/php/ext/xdebug.so
But the file does exist there.
The author of robshouse.net moved his website to Drupal Gardens and did not migrate the article linked to in the question. However the article is somewhat outdated.
You do not need to download anything to enable xdebug in current versions of Acquia Dev Desktop.
Simply uncomment the line that mentions xdebug in /Applications/acquia-drupal/php5_*/bin/php.ini. There are three of these for PHP versions 5.2 5.3 and 5.4 respectively. Make the change in all of them (unless you know better).
You will need to stop and start Acquia Dev Desktop for the change to take effect.
For php -v 7.0.3 users:
ssh: Brew update && upgrade
ssh: brew install homebrew/php/php70-xdebug
ssh: php -m
Check that the module is installed. Then copy the entire
usr/local/Cellar/php70/7.0.3/ content to - >
Applications/DevDesktop/php7_0/
ssh: nano /usr/local/etc/php/7.0/php.ini
configure xdebug.so:
ssh: sudo cp /usr/local/etc/php/7.0/php.ini
/Applications/DevDesktop/php7_0/bin/
DONE :-)
I didn't get the XDebug to work either with Homebrew.
Get the working xdebug.so from ActiveState.
http://code.activestate.com/komodo/remotedebugging/
Article about this:
http://debuggable.com/posts/setting-up-xdebug-on-mac-os-x-or-win32-linux:480f4dd6-0240-4a90-8fa1-4e41cbdd56cb

Categories