Is any debugger is installed by default in XAMPP/WAMP server or We have manually download and configure the debugger? Also do recommend the best PHP debugger.
-
I don't have details, because I haven't done php in months, but you can try NetBeans, I believe it supports PHP debugging with XAMPP. Also supports PHPUnit very nicely too :)Zoidberg– Zoidberg2011-12-07 16:10:56 +00:00Commented Dec 7, 2011 at 16:10
-
@Zoidberg, yes NetBeans has a way to debug with xdebug and it can be configured/enabled in xampp.Jeff LaFay– Jeff LaFay2011-12-07 16:13:28 +00:00Commented Dec 7, 2011 at 16:13
-
1When you say "the best debugger", are you willing to pay? As far as I know, Xdebug is the only free alternative.Álvaro González– Álvaro González2011-12-07 16:15:12 +00:00Commented Dec 7, 2011 at 16:15
-
@jlafay Sounds like it is something your currently using, you should put in an answer, you have a guaranteed upvote from me.Zoidberg– Zoidberg2011-12-07 16:15:40 +00:00Commented Dec 7, 2011 at 16:15
-
No I don't use Netbeans.Jeff LaFay– Jeff LaFay2011-12-07 16:36:18 +00:00Commented Dec 7, 2011 at 16:36
2 Answers
If you want to use Netbeans and Xampp with debugging, simply open c:\xampp\php\php.ini and add these rows. It worked for me like a charm.
xdebug.remote_handler="dbgp"
xdebug.remote_enable=on
xdebug.remote_port =9000
xdebug.remote_enable = 1
xdebug.profiler_enable = off
xdebug.profiler_trigger = off
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.profiler_output_dir = "C:\xampp\tmp"
Or check this out: Check this out: https://www.youtube.com/watch?v=HbJOP0YcSjs
Comments
- No debugger is installed by default in xampp
- Yes, you've to manually configure it
- Use Xdebug debugger
These steps worked for me. I'll describe my setup below
My setup: Win 10 Pro, XAMPP 7.3.33, IntelliJ IDEA
Summary
Summary - Installation
- Download xdebug DLL
- put some lines in php.ini
- Restart Apache
Summary - Usage
- Put a breakpoint in your code
- Start listening to debug connections on IntelliJ IDEA
- The debugger will pause at the line when that particular line gets invoked by the server
Details
All the details below have been taken from https://gist.github.com/odan/1abe76d373a9cbb15bed . All credit goes to them
Installing Xdebug for XAMPP with PHP 7.x
Requirements
- XAMPP for Windows: https://www.apachefriends.org/download.html
- Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019
Setup
If the file C:\xampp\php\ext\php_xdebug.dll already exists, you can skip the download.
Download Xdebug for the specific PHP version:
- PHP 7.4 (64-Bit): https://xdebug.org/files/php_xdebug-2.9.7-7.4-vc15-x86_64.dll
- PHP 7.4 (32-Bit): https://xdebug.org/files/php_xdebug-2.9.7-7.4-vc15.dll
- PHP 7.3 (64-Bit): https://xdebug.org/files/php_xdebug-2.9.7-7.3-vc15-x86_64.dll
- PHP 7.3 (32-Bit): https://xdebug.org/files/php_xdebug-2.9.7-7.3-vc15.dll
- PHP 7.2 (32-Bit): https://xdebug.org/files/php_xdebug-2.9.7-7.2-vc15.dll
- PHP 7.1 (32-Bit): https://xdebug.org/files/php_xdebug-2.9.7-7.1-vc14.dll
- PHP 7.0 (32-Bit): https://xdebug.org/files/php_xdebug-2.6.1-7.0-vc14.dll
Move the downloaded dll file to:
C:\xampp\php\extOpen the file
C:\xampp\php\php.iniwith Notepad++Disable output buffering:
output_buffering = OffScroll down to the
[XDebug]section (or create it) and copy/paste these lines:
[XDebug]
zend_extension = "c:\xampp\php\ext\php_xdebug.dll"
;zend_extension = "c:\xampp\php\ext\php_xdebug-2.9.7-7.4-vc15-x86_64.dll"
xdebug.remote_autostart = 1
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "c:\xampp\tmp"
;xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_log = "c:\xampp\tmp\xdebug.txt"
xdebug.remote_port = 9000
xdebug.trace_output_dir = "c:\xampp\tmp"
;36000 = 10h
xdebug.remote_cookie_expire_time = 36000
Restart Apache
Click the Github ★ Star button :-)
PhpStorm
- Use the PhpStorm bookmarklets generator to activate Xdebug from the browser side.
- Enable the Xdebug option: "Can accept external connections". See screenshot
Netbeans
- Change the Netbeans debugging options: https://user-images.githubusercontent.com/781074/39868196-c98f15a0-5458-11e8-8143-d8c44079e099.jpg
- Change the following key in php.ini:
xdebug.idekey="netbeans-xdebug"
Visual Studio Code
- Installing XDebug on anything for VSCode in 5 minutes
- Install the PHP Debug Adapter for Visual Studio Code.
- Debug PHP In VSCode With XDebug
Adobe Brackets
- Install the PHP Debugger for Brackets.
Sublime Text 2 and 3
- Install the Xdebug Client Package
Start debugger from the console
Enter cmd:
set XDEBUG_CONFIG="idekey=xdebug"
php test.php
Postman
Add XDEBUG_SESSION_START=PHPSTORM as query parameter to the url, e.g.
- http://localhost?XDEBUG_SESSION_START=PHPSTORM