Where is xdebug config on homebrew httpd/php? - php

I am working on MacOS High Sierra and have httpd 2.4 and php 7.1 installed via homebrew. I have php.ini file in /usr/local/etc/php/7.1/php.ini (with extra files in /usr/local/etc/php/7.1/conf.d, including ext-xdebug.ini.
This xdebug.ini contains the following:
[xdebug]
zend_extension="/usr/local/opt/php71-xdebug/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_port=9001
xdebug.idekey=INTELLIJ
If I run on command line php -i |grep xdebug, I get all the xdebug settings, including the ones above.
Yet, if I put a php file into the web root with phpinfo() in it and access it via the browser, I get the following (among other):
xdebug.remote_enable = false
xdebug.remote_port = 9000
xdebug.idekey = _www
Where are these values set? I can't find any other config file anywhere.

This was silly of me. After updating php.ini, I restarted apache, but I didn't restart php-fpm. Naturally, as the php process was still running, it had cached the settings. After I restarted php-fpm (brew services restart php71) the new settings were picked up and debugging now works as expected.

Related

php7.4 Xdebug xdebug.mode = debug is not working for me

I have installed Xdebug on a Ubuntu 20.04 system. I followed this documentation , which I found to be quite well written, and got everything installed per the specs. (I used apt rather than yum, and placed the .so file into /usr/lib/php/20190902 folder rather than the document's example.)
In that document, there is a reference to adding to the php.ini file (I added to /etc/php/7.4/apache2/php.ini and /etc/php/7.4/cli/php.ini files). Since the article doesn't specifically mention "sections" of the .ini file, I put them within the [PHP] section. (This is consistent with the remark about putting right before the Quick Reference bit.) I restarted Apache2 and the phpinfo() output now includes Xdebug, which it did not include before. All well and good.
The trouble I'm having is that although I set xdebug.mode = debug in the php.ini files, the phpinfo() output tells me that xdebug.mode is set to develop. Consequently, Step debugger shows as Disabled in my configuration. I cannot see why.
These are the lines I've added to each of those php.ini files:
zend_extension=xdebug.so
#zend_extension=/usr/lib/php/20190902/xdebug.so
xdebug.mode=debug,develop,trace
[xdebug]
xdebug.remote_host=localhost
xdebug.remote_connect_back=0
xdebug.remote_enable=1
xdebug.remote_port=9900
xdebug.idekey="PHPSTORM"
xdebug.remote_log="/tmp/xdebug.log"
xdebug.remote_handler=dbgp
xdebug.show_error_trace = 1
xdebug.log_level = 7
xdebug.start_with_request=yes
xdebug.mode=debug,develop,trace
And here are the key excerpts from the phpinfo() output:
On a whim, I tried placing all of those settings also within a new section of php.ini which I called [xdebug]. When that didn't work, I tried [Xdebug]. I restarted Apache2 after each attempt, but the symptom never changed.
What might I be missing?
For me, being on Ubuntu 22, PHP 8.1 and xdebug 3.1.2, the solution was to edit not the php.ini file but the xdebug.ini. For example :
sudo nano /etc/php/8.1/cli/conf.d/20-xdebug.ini
After this a restart for apache
sudo service apach2 restart
Then I was able see the changes in phpinfo and finally connect to PHPStorm debugger.

configure xdebug for php 7.1.28

I configure xdebug by flowing https://xdebug.org/wizard.php, and I'm pretty sure that I used the right phpize(/opt/lampp/bin/phpize-7.1.28), and after I compile, I put it in /opt/lampp/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so, here is the part of my /opt/lampp/etc/php.ini :
[XDebug]
xdebug.remote_enable=1
xdebug.remote_port=9000
zend_extension = /opt/lampp/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
Then, I restart my apache server, when I check out phpinfo, there is still no xdebug.
BTW, is there any possible that my php version can not be configured with xdebug, because I noticed that the extension directory is no-debug-non-zts-20160303

How to install PHP Opcache on MacOS High Sierra?

I'm using the standard Apache and PHP 7.1 (not Homebrew) that comes with Mac High Sierra. However, it appears that this version doesn't have Opcache enabled even though it should come as standard with PHP 7. It's even listed in phpinfo() under "Module Authors", but no section showing it's actually installed. Calling opcache_get_status gives a fatal error.
I've installed the extension via Homebrew, and linked the opcache.so file. It appears to be working on the CLI but not in Apache. For some reason the CLI and web are using different ini files:
/usr/local/etc/php/7.1/php.ini for CLI
/etc/php.ini for web
The CLI is parsing the addition files including /usr/local/etc/php/7.1/conf.d/ext-opcache.ini, and php -i shows Opcache. But phpinfo() in the browser does not - no additional ini files are parsed.
I currently have this in /etc/php.ini:
[opcache]
zend_extension="/usr/local/opt/php71-opcache/opcache.so"
opcache.enable=1
But still nothing. I followed the exact same process for xdebug and it worked fine. What am I missing?
I wonder if it would be easier to use the Homebrew version of PHP. But I don't appear to have the required .so file. Various tutorials say to put this in Apache's httpd.conf:
LoadModule php7_module /usr/local/opt/php71/libexec/apache2/libphp7.so
But the libexec directory does not exist. There is lib but neither this nor any other directory has any .so file.
For me it worked by these steps:
Search extension_dir in "phpinfo()" page, I got a path
/usr/lib/php/extensions/no-debug-non-zts-20160303
By execute ls -lh /usr/lib/php/extensions/no-debug-non-zts-20160303, I found "opcache.so" , I guess it's installed when upgraded to "High Sierra"
Create "/etc/php.ini" (by copy "/etc/php.ini.default"), and modify:
[opcache]
zend_extension = opcache.so
opcache.enable = 1
Restart apache, module "opcache" is enabled
EDIT / CONCLUSION
Since "opcache extension" is installed on Mac OS High Sierra by default, the solution of enabling opcahe on Mac OS High Sierra is:
Create "/etc/php.ini" if you don't have one, by simply copy the default configuration: sudo cp /etc/php.ini.default /etc/php.ini
Add zend_extension = opcache.so to /etc/php.ini and set "opcache" enable:
php.ini opcache section looks like:
[opcache]
zend_extension = opcache.so
opcache.enable = 1

Netbeans + Xdebug + php not working

My netbeans does not work the breakpoints using xdebug, my configuration looks correct, so I configured the first time I ran up to stop debugging the first time since then has never worked, someone had this problem? The version of my netbeans is 6.8 and the version of php is 2.5.2.
my php.ini:
zend_extension_ts = d:\wamp\bin\php\php5.2.5\ext\php_xdebug-2.0.2-5.2.5.dll
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.idekey=netbeans-xdebug
xdebug.profiler_enable=1
In my case this line needed to be included in the php.ini:
xdebug.remote_autostart=on
Here is the configuration section for XDebug:
[xdebug]
xdebug.remote_enable = on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.idekey="netbeans-xdebug"
xdebug.remote_autostart=on
xdebug.profiler_enable = on
xdebug.profiler_enable_trigger = on
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "d:/wamp/tmp"
Checklist for xdebug:
Check that xdebug is loaded in phpinfo(), and the runtime value matches expected configuration.
xdebug.remote_enable is on.
xdebug.extended_info should be on for breakpoints to work.
xdebug.remote_port must be same as ide and unused.
xdebug.remote_handler is dbgp.
xdebug.idekey should be set to same as ide's key if xdebug.remote_autostart is on.
Sometimes it help to set xdebug.remote_host to intranet IP or computer name instead of local ip 127.0.0.1. PHP must be allowed by Firewall to connect to this host and port.
Setting xdebug.remote_log to a file will help in checking what is wrong. Disable the log once debug is working.
Sample config:
[xdebug]
xdebug.extended_info=on
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=on
xdebug.idekey="netbeans-xdebug"
Checklist for NetBeans:
Firewall must allow Netbeans to listen for connection with configured host.
Tools -> Options -> PHP -> Debugging, check port. Also check session id if xdebug.remote_autostart is on.
Project type must be PHP.
Project Properties -> Source, web root must be correct.
Project Properties -> Run Configuration, index file need to be a php (or empty) for Ctrl+F5 to work.
Project Properties -> Run Configuration -> Advanced, debug url should be "Default" or "Ask Everytime".
Project Properties -> Run Configuration -> Advanced, path mapping must be correct. (e.g. empty if there are no mappings)
(Most default options work out of the box, so if you are desperate try to delete and recreate the project.)
False Instructions, tested on PHP 5.5 and xdebug 2.2:
PHP output_buffering does not need to be off. (But may help in debugging)
OPCache (Zend Cache) module can be loaded.
xdebug.profiler_enable can be enabled.
Please edit this answer if you found something new.
Check that you have the right version of Xdebug for your version of PHP (including Thread-safe/non-thread-safe and 64bit/32bit).
In some newer versions of PHP, you need to use zend_extension, not zend_extension_ts, regardless of whether you have the TS version of Xdebug.
(I am replying with an Answer since the formatting in comments wasn't working properly)
Same happened for me: worked once and then stopped. However, I reached a point in my config where it started working without problems and I can share.
First I moved on top of php.ini the ioncube loader:
[PHP]
zend_extension=/Applications/MAMP/bin/php5/zend/lib/ioncube_loader_dar_5.2.so
Then I put these lines in the xdebug config:
[xdebug]
zend_extension="/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so"
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
And commented out all the lines about Zend Optimizer
[Zend]
;zend_optimizer.optimization_level=15
;zend_extension_manager.optimizer=/Applications/MAMP/bin/php5/zend/lib/Optimizer-3.3.3
;zend_optimizer.version=3.3.3
I work on MAMP, this is why the paths to my libraries are referred to my MAMP folder.
Good luck
zend_extension = "C:\xampp\php\ext\php_xdebug-2.2.3-5.4-vc9.dll"xdebug.remote_enable = 1 xdebug.remote_handler = "dbgp"xdebug.remote_host = "localhost" xdebug.remote_port="9000" xdebug.remote_mode=req xdebug.trace_output_dir = "C:\xampp\tmp" xdebug.idekey="netbeans-xdebug"
this is working for me..
Here's how I was able to get it to work w/ mulitple PHP-FPM homebrew installations.
I used this excellent article for the multiple installations:
https://echo.co/blog/os-x-1010-yosemite-local-development-environment-apache-php-and-mysql-homebrew
In the comments of that post you'll see recommended how to install xdebug, bottom line:
brew install php56-xdebug
You have to install xdebug for each verions of PHP you have installed. Homebrew will make a xdebug.ini file for each version of php you installed. Each will have a path like:
/usr/local/etc/php/<version # i.e. "5.6">/conf.d/ext-xdebug.ini
This article installs DNSMasq which runs on xdebug's default port (9000), so you'll need to change the xdebug port to something else (9001 works fine.)
Edit the above mentioned ext-xdebug.ini file (or files if you installed more than one version of php.) Here's what works for me:
[xdebug]
zend_extension="/usr/local/opt/php56-xdebug/xdebug.so"
; General config
; Dumps local variables on exception
xdebug.show_local_vars=On
; Dump server variables
xdebug.dump.SERVER=*
; Dump global variables
xdebug.dump_globals=On
xdebug.collect_params=4;
; Tracing
;xdebug.auto_trace=On
;xdebug.trace_output_dir= /opt/local/php_traces/
xdebug.show_mem_delta=On
xdebug.collect_return=On
; Debugging. You might need to specify your host with some additional options
xdebug.remote_enable=1
: from http://devzone.zend.com/1147/debugging-php-applications-with-xdebug/
xdebug.remote_host="localhost"
xdebug.remote_port=9001
xdebug.remote_handler="dbgp"
The first two lines are all that is in the original homebrew file.
BTW - when I installed multiple PHP versions, this ext-xdebug.ini file was only created for the first PHP version I installed. I simply copied this file to the other PHP version locations, and changed the "php56-xdebug" part of the path in line 2 to reflect the proper php version.
Notice "xdebug.remote_port=9001"
Then in Netbeans (I'm using 8.02 Mac osX10.10.3) I use the following settings.
Go to Preferences->PHP->Debugging
Debugger Port: 9001
Stop at First Line: (unchecked)
Watches & Balloon Evaluation: (checked - there's a warning but it works fine for me.)
Also worth noticing is that in order for xdebug to show up using phpinfo() (or command line php -i) I need to restart apache with:
launchctl unload -Fw ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
sudo apachectl restart
launchctl load -Fw ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
For some reason my setup requires me to run this every time I startup. Kind of a pain, but I incorporated it in a shell command to easily switch between versions.
One more hint: part of brew info php56 says:
OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using
the brew version you need to make sure /usr/local/sbin is before /usr/sbin
in your PATH:
PATH="/usr/local/sbin:$PATH"
Until I added this to my .profile_bash file, changes I made to each version's php-fpm.conf file were not recognized. Everything else seemed to work so it was confusing.
Hope this saves someone else time & trouble.
If you are still stuck you could try the following:
Download a new version of xdebug via the wizard (http://www.xdebug.org/wizard.php) and if you follow the instructions maybe you will be lucky.
Switching off the firewall might help.
Use a different port in netbeans, for instance in my case using 9001 in netbeans and 9000 in xdebug worked.
Add to php.ini file: xdebug.idekey=netbeans-xdebug.
Find out if you have a xdebug.ini file and add the xdebug related php.ini lines to that file.
Always make sure that you restart your apache service to test everything.
In my case - host is on another server, Net-beans 11 - I need to open terminal to remotehost
Window -> IDE Tools -> Terminal -> Remote Terminal
P.S. If u type export XDEBUG_CONFIG="idekey=netbeans-xdebug" in that terminal, and start debugging session, u can debug console scripts

Xdebug configuration with PHP fastcgi and eclipse?

I have been using eclipse-pdt in conjunction with xdebug and apache without problems, for over one year. Things worked flawlessly and I could do all the interactive debugging I wanted from within eclipse (using my own machine as a server).
Now I switched from apache to nginx (and therefore PHP runs now not as an Apache service but as fast-cgi) and I can't find a way to configure eclipse to work nicely with xdebug. I am neither sure if the problem is with xdebug or with eclipse (or both) to be sure.
In the eclipse configuration I already changed the reference to the PHP configuration file to /etc/php5/cli/php.ini.
Attempts with php.ini version 1
With the following php.ini file
zend_extension=/usr/lib/php5/20060613/xdebug.so
I see that xdebug is working (for example if I do a var_dump() I get the xdebug version of it, not the plain PHP one)
I can't have the interactive debugging from eclipse: the browser opens up and loads the page completely with the typical URL containing ...?XDEBUG_SESSION_START=ECLIPSE_DBGP&KEY=..., but the program execution does not stop at breakpoints
In the bottom-right corner of eclipse I see a suspicious message: "Launching =put_the_name_of_my_project_here=: 57%" that alternates with the "refreshing workspace" one.
Attempts with php.ini version 2
If I use this other version of the file (which is what it worked until I switched to nginx):
zend_extension=/usr/lib/php5/20060613/xdebug.so
xdebug.remote_enable=On
xdebug.remote_autostart=On
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_mode=req
I can't access any page of my sites at all.
PS: Additional data on my machine:
- OS: GNU/Linux - Ubuntu 9.10 64 bit.
- PHP: 5.2.10-2ubuntu6.3 with Suhosin-Patch 0.9.7; Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies with Xdebug v2.0.4
- Eclipse: see screenshot.
xdebug and FastCGI use the same default port (9000). Change the port of XDebug in your php.ini file like this:
xdebug.remote_port=9001
and update your IDE settings to use 9001.
What Beau said is correct (couldn't vote since I'm new!).
Generally, addging to /etc/php5/cgi/php.ini (or locate php.ini) the lines like
zend_extension = /PATH_TO/xdebug.so ## <-- NOTE the absolute path, not relational (For ex on Windows: "C:\nginx-1.9.13\php\ext\php_xdebug-2.6.0RC2-7.0-vc14-nts.dll")
xdebug.remote_enable = on
xdebug.remote_handler = dbgp
xdebug.remote_host = localhost
xdebug.remote_port = 9900 ## <-- Yours will be probly 9000 or other..
does the job.
So after the change,
./php-fastcgi stop
./php-fastcgi start
This worked for me.
Try restarting your php. Because you have php-fastcgi, restarting nginx doesn't seem to do it. When I rebooted my whole server the change took effect.
I had the same problem and solved it.
In file /etc/php5/apache2/php.ini add:
[xdebug] xdebug.remote_enable=On
xdebug.remote_autostart=off
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_mode=req
In file /etc/php5/cli/php.ini add:
zend_extension=/usr/lib/php5/20060613/xdebug.so
xdebug.remote_enable=On
xdebug.remote_autostart=off
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_mode=req
Restart Apache:
sudo service apache2 restart
Problem in solution is "xdebug.remote_autostart = on".
If you set in file config "xdebug.remote_autostart = on". This will force Xdebug to start a debug session for every request that is done on this server, without having to specify in the request that a debug session is wanted.
You need change
"xdebug.remote_autostart = off"
And restart web service.
In this example is Apache.
You can read more here: http://doc.waterproof.fr/phpedit/debugging_profiling/configuration/debugger_with_xdebug
GoodLuck!

Categories