I want to use Xdebug tool for profiling code execution speed, memory usage of my php application.
My application frame work is codeigniter and IDE is PhpDesigner.
i followed the instruction in phpDesigner manual PhpDesigner xdebug configuration
But when i debug using debug option f9 in PhpDesigner menu it shows Php5.dll file is missing.
How to debug my php script using xdebug and phpDesigner
I'm using external debugging for projects on my local server.
To debug file you just need to open it in IDE and run script from browser.
Look at this tutorial http://wiki.mpsoftware.dk/doku.php/tutorials/debug_php_scripts_from_your_browser_with_phpdesigner_7_external_debugging
Related
I am using VS Code to debug a php file. I have installed the PHP Debug extension and configured PHP to debug using XDebug. Server is Apache (using Xampp).
The file I want to debug is in .../htdocs/Nuurd and breakpoints are hit. But when I open another folder and try to debug a file in (for instance) .../htdocs/Test it cannot be debugged, i.e. the program is finished without stopping at any breakpoint (it runs through).
Why does it depend on the folder and what settings are required to make xdebug work on any folder?
The folder .vscode with launch.json was missing.
I copied it from another folder and that solved the problem (hopefully forever).
I am using the gdbserver plugin in Netbeans trying to attach to a remote debugging session. However I get an error: "inappropriate ioctl for device." I am able to remote debug by launching gdb from the terminal but I would like to be able to use Netbeans for debugging.
I had this problem too. I was able to fix it by running the "debugger" "Using GDB Debugger" on my project. It failed, because my project doesn't run on this machine. But after doing this, I was able to successfully run the "debugger" "gdbserver".
so im trying to get sublime text 2 to run along with x-debug i have installed the
Kindari-SublimeXdebug
and i have wamp (i have enabled xdebug )
here is the php.ini configuration
; XDEBUG Extension
zend_extension =
"c:/wamp/bin/php/php5.3.10/zend_ext/php_xd
ebug-2.1.2-5.3-vc9-x86_64.dll"
[xdebug]
xdebug.remote_enable = On
xdebug.profiler_enable = On
xdebug.profiler_enable_trigger = On
xdebug.profiler_output_name =
cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
xdebug.remote_connect_back = On
xdebug.remote_autostart = On
but still every time i try to connect to it through sublime it though :
Xdebug : is not running
even though in my phpinfo() ; it shows that it runs probably ..
sorry im still new to x-debug and sublime ...
thanks in advance
I think you need to add the following lines to the xdebug configuration in php.ini:
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
Although it sounds like you moved on, I'll add this for anyone else coming across your question...
I'm also running WAMP and had no problems getting Xdebug to work with Sublime Text 2. Make sure you follow the Tailored Installation Instructions for Xdebug, which should set you up with the appropriate Xdebug DLL and php.ini statements (make sure you're editing the correct php.ini!), equivalent to the following (which pretty much match what #Duke and #jasonmcclurg already said above):
zend_extension = "D:\Program Files (x86)\Wamp\bin\php\php5.3.6\ext\php_xdebug-2.2.2-5.3-vc9.dll"
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
You can check if Xdebug is properly installed on your local server by checking the output of phpinfo(), refer to the Xdebug FAQ for some specifics.
As per SublimeXdebug's Readme, use Shift+F8 in Sublime and select Start Debugger from the drop down that appears, then set a breakpoint in your PHP code (put the caret on the desired line of PHP code, press Shift+F8, select Add/Remove Breakpoint).
To trigger remote debugging (get xdebug to connect), append the query string?XDEBUG_SESSION_START=1 to your local site's URL (e.g., http://localhost/index.php?XDEBUG_SESSION_START=1) or use a browser extension/addon that does the equivalent for you (e.g., xdebug_session helper for Chrome, or, which is what I use, easy Xdebug for Firefox). Yet another alternative is to have SublimeXdebug trigger remote debugging automatically, see refer SublimeXdebug's Readme for details.
Once your browser requests a page which references the PHP file with your breakpoint (and assuming the PHP interpreter actually reaches the specific line with your breakpoint, i.e., your script doesn't branch elsewhere, or your app/CMS doesn't return a cached page, possibly forfeiting execution of your script), execution should halt at the breakpoint...
If everything is set up correctly but your breakpoint is not reached, SublimeXdebug briefly displays "Xdebug: Page finished executing. Reload to continue debugging." on Sublime's status bar when the browser finishes loading a page.
Up until recently, I've been writing code in PHP (via Notepad++) and debugging by checking the logs in IIS (gotta love that web-platform installer); I've since decided to update to a more efficient code-writing / testing environment, and after playing around for several moments with PHPStorm, decided to purchase it and give it a try. Since then, I have realized that in so far as tutorials and walk-throughs are concerned, PHPStorm is coming up a little short. Having given the manual a glance (RTFM, I know), and come up wanting, I'd like to ask if anyone out there would like to hand hold me through setting up PHPStorm with XDebug so I can stop hating myself for not studying the underlying systems well enough, and get back to coding.
TLDR; Could someone post a detailed walk-through for setting up PHPStorm + XDebug? Assume maximum level of stupidity on my part (I"m usually more than capable in the ASP.NET world, but I am approaching the intelligence level usually associated with some forms of sea-faring sponge in the PHP world).
The environment is Windows 7 Ultimate (64-bit) with IIS & PHP installed.
I've found a more modern and easier solution partially based on CrasyCoder's post.
The steps you need to do are the following:
If your brand new php installation doesn't contain php.ini, rename the php.ini-development to php.ini
Install xdebug with help of the wizard: http://xdebug.org/wizard.php Follow its recommendations literally.
Put in your php.ini the string: xdebug.remote_enable=1
Go to PhpStorm's settings: settings->php. Select or reselect directory containing php. Make sure you see 'Debugger: Xdebug x.x.x' string (where x.x.x stands for installed version)
Install an extension for your favorite browser from here: http://xdebug.org/docs/remote
From the main menu (not the settings window) go to 'Run->Edit configurations' and add new 'PHP Built-in Web Server' configuration. Point the 'Document root' to your project's directory. Note the port number.
Chrome browser: enable the extension pressing on the little bug in the rightmost side of the omnibox and selecting the Debug option. Other browsers' extensions should work similarly.
In PhpStorm's menu enable the 'Run -> Start Listen for PHP Debug connections' option.
Set a breakpoint in your code in PhpStorm.
Run (not debug) the configuration you created in step 6.
In your browser go to localhost:port where 'port' is the port from step 6. Your PhpStorm should stop on the breakpoint and you can start squashing bugs in your code.
Considering that:
Steps 1-5 are made once per php installation.
Step 6 is made once per PhpStorm project.
Steps 7-8 are made once per debuggin session.
Steps 9-11 are made each program run.
It's really simple to get Xdebug working with PhpStorm, just follow this guide carefully. (NOTE: Updated version of the guide is here)
For more advanced topics read this.
1. install xdebug module (MAC installation steps)
1.1.1. check what PHP version u r using php --ini (see the loaded file)
1.1.2. brew search xdebug
1.1.3. brew install phpXX-xdebug
1.1.4. see details: php -i | grep xdebug
1.2. restart server
1.3. configuration
1.3.1. sudo find /usr -name 'xdebug.so'
1.3.2. copy the path of the exact one you need
example: /usr/local/Cellar/php56-xdebug/2.3.2/xdebug.so
1.3.3. edit the extension related configuration file which should be injected to the main php.ini automatically:
subl /usr/local/etc/php/5.6/conf.d/ext-xdebug.ini
1.3.4. add the zend_extension to be = the path copied above
[xdebug]
zend_extension="/usr/local/Cellar/php56-xdebug/2.3.2/xdebug.so"
Normal file should have something like this:
[xdebug]
zend_extension="/usr/local/Cellar/php56/5.6.4/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.remote_autostart=1
xdebug.profiler_enable=1
xdebug.profiler_output_dir="~/xdebug/phpstorm/tmp"
xdebug.idekey=PHPSTORM
2. check your PHP version
php --ini
3. setup the IDE settings
preference > languages and framework > PHP >
3.1. set the language level to the correct PHP version of this project
3.2. set an interpreter (set the parent directory of where the bin directory of PHP executable is loaded)
3.2.1. click the … button > click the + button > other local > set PHP Excitable path,
to find the path type in the terminal: $ which php
example: /usr/local/Cellar/php56/5.6.5/bin/php
4. restart phpstorm
5. now let’s make it work
5.1. run > edit configuration > click the green + button on the left > select b. php web application
5.2. name: anything example ur {application name - debugger}
5.3. server: localhost (browse > + > name: whatever | host: localhost or 127.0.0.1)
5.4. click ok
5.5. start url: the link of ur project homepage: http://127.0.0.1:80/SomethingNew/
5.6. click ok
6. now set the break point and click debug
I had quite some troubles when I touched XDebug remote debugging the first time yesterday.
A few general hints, you are overflown with various tutorials and guides anyway.
Your XDebug configuration on PHP/Aache side:
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
xdebug.remote_connect_back=1
You need to either use remote_connect_back as given above (be careful, this means other people can debug your server too while it is enabled) or you specify your IP address (remote_host).
On Client Side you need to have your router forward the Port 9000 !
You need to allow PHPStorm for incoming connections in your Firewall (was not enabled by default on Windows 8 for me). Either open Port 9000 or the app itself.
On PHPStorm make sure to go into Debug configuration and not use the default debug (PHPUnit!) Use "PHP remote debug" (Run/Debug Configurations -> The PLUS sign on upper left)
You will need to tell PHPStorm the absolute path of your project on the webserver, if you make an error here (and forget that) you will get a prompt anyway.
Now Debug your project in PHPStorm while having "Listen for connections" enabled and put a breakpoint into your code.
With your webbrowser open your website/php file while having a cookie enabled that starts the debugger. (cookie is the best approach in most cases). You can use a bookmark (google for phpstorm debugging bookmark) or an extension.
Even following the guides, I missed several of the above points. I hope I could save some hours of struggling :)
If you don't need remote debug, you can easily debug your project.
First check your php.ini settings.
Be sure that your xdebug dll exists and the settings are on.
xdebug.remote_enable = on
xdebug.profiler_enable = on
xdebug.profiler_enable_trigger = on
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
xdebug.show_local_vars=0
Then go to Run menu in top navbar. Then select edit configurations and add new configuration ( do not change your default settings for another project )
Click add new item button.
After adding new php web application
If you do not have any server ( generally points the localhost with 80 port on windows or linux ) click the button shown as below.
Add a new server with xdebug.
Then click ok and check your configuration
Finally, you will see the configuration at the right side of ide.
Click RUN or DEBUG button.
install xdebug on your local PHP - actually update your php v with xdebug included:
https://floyk.com/en/post/how-to-update-php-version-on-your-macbook-macos-sierra
setup your xdebug.ini
zend_extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so
[xdebug]
xdebug.remote_enable=on
xdebug.default_enable=on
xdebug.remote_autostart=off
xdebug.remote_port=9000
xdebug.remote_host=localhost
xdebug.profiler_enable_trigger=1
xdebug.profiler_output_name=xdebug-profile-cachegrind.out-%H-%R
xdebug.var_display_max_children = 128
xdebug.var_display_max_data = 512
xdebug.var_display_max_depth = 3
xdebug.remote_enable = 1
xdebug.idekey = PHPSTORM
xdebug.show_error_trace = 1
xdebug.file_link_format = phpstorm://open?%f:%l
Install Xdebug helper to your Chrome browser:
Install Xdebug helper
in your PhpStorm go to Settings/Preferences->Languages & Frameworks->PHP->Debug
Update your Automatically detect IDE IP if needed, and press OK
You are done.
More detailed "step by step" guide you can find here:
https://floyk.com/en/post/how-install-php-with-xdebug-on-mac-os
I've succecfully installed xdebug 2.2.0-dev and my phpinfo() shows all the options, but I can't get it work with my IDE. In my IDE when I click at the option "Listener status" I see the number "Total connections" changing when I try to debug but the script simply doesn't stop at my breakpoint nor at the command xdebug_start(). I use a reverse shell to my server but when I telnet to Port 9000 on my localhost I get the error message: Name or service not known??? What can I do? Install the stable 2.1.2? When I start lighttpd I get this warning:
Xdebug requires Zend Engine API version 220060519.
The Zend Engine API version 220090626 which is installed, is newer.
Contact Derick Rethans at http://xdebug.org for a later version of Xdebug.
There are a few things going wrong there. The big warning at the bottom only says that you have compiled Xdebug against the headers for the wrong PHP version. Do you have multiple sets of headers? If so: remove the ones you don't need.
Your telnet command is likely wrong, you use it like "telnet localhost 9000". Breakpoints not stopping is possible because you have not set-up path mappings in Komodo.