How to enable XDebug extension on my php? - php

I am running php on a macbook pro running mountain lion.
Mountain lion comes with XDebug pre-installed, so based on a tutorial I've found , I made three steps.
First I've uncomment this line in my php.ini :
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
Secondly I've uncomment this line in my php.ini :
xdebug.remote_enable=1
And finally I restarted the apache server with :
sudo apachectl restart
The problem is that I see no xdebug appearing in my php details when I run a phpinfo().
Thank you.
PS : The path of the above xdebug.so file is correct.

I am answering my own question because Mountain Lion is a special case when it comes to running XDebug.
As you can see here,
mountain lion comes with an older xdebug.so library. So the user must re-compile the library himself.
Here is how to do it.
Download the latest version here. (We get the file under the
source link.)
Unpack the downloaded file with tar -xvzf xdebug-2.2.1.tgz
Run cd xdebug-2.2.1
Run phpize
Run ./configure
Run make
Run sudo cp modules/xdebug.so
/usr/lib/php/extensions/no-debug-non-zts-20090626
Restart the web server with sudo apachectl restart

Check you are editing the same php.ini that shows up in phpinfo() in the broswer.
Here are my settings (I'm also on a Macbook Pro on Mountain Lion btw):
xdebug.var_display_max_children = 999
xdebug.var_display_max_data = 99999
xdebug.var_display_max_depth = 100
;zend_extension_ts=php_xdebug.dll
xdebug.remote_enable=On
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
Works for me. Does any of that help?

This set of instructions worked for me.
It successfully uses OSX Mountain Lion's native Apache2 and XDebug together with MacGDBp and a Safari extension called XDebug Helper.

Related

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 on macOS 10.13 with PHP 7

So macOS High Sierra 10.13 now comes with PHP 7.1. While configuring Apache I also created a new /etc/php.ini from the /etc/php.ini.default file, made sure to check that is was being loaded by PHP after restarting Apache, however the version of Xdebug extension that ships with macOS 10.13 doesn't seem to load or show up when you run phpinfo();
My php.ini is definitely being loaded:
$ php -i | grep php.ini
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
Here's what my /etc/php.ini looks like where I configure Xdebug:
[xdebug]
zend_extension = "/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so"
xdebug.remote_enable=on
xdebug.remote_log="/var/log/xdebug.log"
xdebug.remote_host=localhost
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
[Update, fixed that typo here...]
However, Xdebug doesn't load and checking php -i give no results:
$php -i | grep xdebug
PHP Warning: Method xdebug_start_function_monitor() cannot be a NULL
function in Unknown on line 0
PHP Warning: xdebug: Unable to register functions, unable to load in Unknown on line 0
Segmentation fault: 11
And yes, the path to the file is correct:
$ ls /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so*
This used to work on PHP 5 so I hope someone can help me and anyone else in future struggling with this issue.
When I check my apache log I get the following error:
Failed loading /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so: dlopen(/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so, 9): Symbol not found: _xdebug_monitored_function_dtor
Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
Expected in: flat namespace
in /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
I'm not making progress in terms of find out how I can resolve this error:
Symbol not found: _xdebug_monitored_function_dtor
Ok so I finally got it running myself it works perfectly! I'm assuming that the xdebug binary that comes with macOS High Sierra (found under: /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so) is not compatible with PHP7's new Zend engine.
So I downloaded the latest source from the xdebug website and did the following:
Installed autoconf with brew;
Run phpize to configure the build for the new Zend engine;
Run ./configure
Run make
Now the new binary is under modules/xdebug.so
However macOS System Integrity Protection (SIP) will prevent you from overwriting the xdebug.so under /usr/lib/php/extensions/. I didn't want to disable this so I created a new directory path under /usr/local/lib/php/extensions/ and copied the new binary to this location. I'm not sure if this directory is the best place to put it or if this is bad practice but it worked for me.
Finally I reconfigured my php.ini to use the new binary and everything worked perfectly!
In order to install it you have to have xcode command line tools.
So you need to run:
xcode-select --install
Then you need to install autoconf:
brew install autoconf
Then you have to download the code from here.
After that you have to run in the folder of the source code:
phpize
./configure
make
sudo cp modules/xdebug.so /usr/local/php/extensions (if the directory doesn't exist go and create it)
And finally inside php.ini add
zend_extension=/usr/local/php/extensions/xdebug.so
After that you can enable xdebug inside php.ini and restart apache
sudo apachectl restart
you made a typo in "zend_extention". this should be zend_extension.
and i think the full path is unnecessary
zend_extension=xdebug.so
should be enough
If you have brew installed with multiple PHP versions i.e. 7.1, 7.2 and 7.3 on Mac OS X mojave, you can to do the following:
Install autoconf with brew brew install autoconf.
Change to the PHP version that you want Xdebug on, run brew unlink php#7.1 && brew link --force --overwrite php. This will switch from PHP 7.1 to PHP 7.3.
Download the latest Xdebug source from xdebug website.
Extract the Xdebug tar and navigate to extracted directory, where you'd see all the files.
Run phpize to configure the build for the new Zend engine.
Run ./configure.
Run make.
Xdebug extension xdebug.so gets compiled in modules directory.
Create a new directory path under /usr/local/lib/php/7.3.1/extensions/ and copy xdebug.so to this location. Here, 7.3.1 is the current version that I switched earlier, change this to match your PHP version.
Open php.ini in an editor and enter
zend_extension="/usr/local/lib/php/7.3.1/extensions/xdebug.so" then save the change.
Run php -v and it will show Xdebug has been configured correctly.
If you want to configure Xdebug on another PHP version then just repeat from step 2 all the way to 11. As mentioned in earlier post, this way you don't need to disable/enable System Integrity Protection on Mac OS X.
For anyone arriving late at this party, the initial attempt in the question seems to work just fine in macOS 10.13.6
Hello for everyone that got error trying to install xDebug on Mac.
error: unknown type name 'uint64_t'
There are files in your local/bin/include that causes this error. By removing them you get rid of the error. Though, you might have to reinsatall brew.
https://github.com/cython/cython/issues/2009

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

How to get Xdebug to work on a Mac

I have spent a lot of time on this with no end product.
Installed MAMP.
Found "make" (was installed in different folder)
Installed autoconf which was missing so I can run phpize
Downloaded, compiled and installed xdebug according to:
http://www.xdebug.org/find-binary.php
Made necessary changes to correct php.ini.
Restarted MAMP - but phpinfo() does not show xdebug.
No matter what I do to the php.ini file located at /Applications/MAMP/conf/php5.3/php.ini, nothing changes. The site still loads fine. Even if I nuke it completely. Yet that is what phpinfo() shows it is loading.
What am I overlooking?
php.ini
[xdebug]
zend_extension=/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1
The site where you can download precompiled binaries of xdebug had been down all morning (activestate) which is why I was trying to compile my own.
I just found out the site was back online, downloaded the xdebug.so file, and it is now loading.
Modern MACs have two kinds of binaries - 32-bit and 64-bit. Verify that you PHP matches your xdebug: do file Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so then file /path/to/mamp/Library/modules/php5.3/libphp5.so and see if they both show i386 or x86_64.
I just did it and it worked. Here is what I did:
install PECL in order to install Xdebug
download http://pear.php.net/go-pear.phar
in the download directory execute php -d detect_unicode=0 go-pear.phar
now add the ~/pear/bin folder to your path echo "export PATH=$PATH:/Users/the-user/pear/bin" >> .bash_profile
and make the change visible to your terminal . .bash_profile
install Xdebug
now that you have PECL it's as easy as sudo pecl install xdebug
now you need to add a line to php.ini
the php.ini on my mac (Lion) is /etc/php.ini.default
search for zend_extension and uncomment the line if it is correct or change it if it is not (in my case it was correct)
That's it. Unless you want to debug form IntelliJ Idea. In which case I had to copy /etc/php.ini.default to /etc/php.ini
have fun with PHP
Just to point out the obvious, but one that I keep throwing away time on; in an apache2 environment remember to restart apache2 for the changes to take effect.
sudo apachectl restart

Categories