Phpstorm Xampp Xdebug



  1. Xdebug: A powerful debugger for PHP. Installation Wizard. This page helps you finding which file to download, and how to configure PHP to get Xdebug running.
  2. MAC+XAMPP+PHPStorm+XDebug 在网上找了半天,花费了很长时间,总结了网上的内容,发现写的都不是十分全面,这里我写了从头到尾的配置过程。 ¶下载并安装XAMPP 首先先去官网下载:click here ps:个人补充一点,由于我上来先安装的是最新版本的导致我出现了许多问题,后来我尝试更换成了php7.3版本的XAMPP.
  3. For more XDebug xdebug.idekey = 'PHPSTORM' xdebug.remoteport = 80 I work with xampp port 80. Now I hit the start deebug bookmark, in the phpStrom press on start to listen to php debug and set any breakpoint in php scope, set the Xdebug extension on Debug mode, browse to localhost/myCode/index.php but no any debugging is occur in the.
  4. Setting up Xdebug and PhpStorm with XAMPP for nicer debugging With xdebug you can set breakpoints in your code, see all defined variable and even change them while running the code. To start we need to download the latest Xdebug version from You have to choose the right version for your installed php version.

From Joomla! Documentation

PhpStorm Use the PhpStorm bookmarklets generator to activate Xdebug from the browser side. Enable the Xdebug option: 'Can accept external connections'.

  • 1Edit PHP.INI File for XDebug

For Windows

Starting with version 1.7, XAMPP includes the XDebug PHP debugger, but it needs to be configured for use. To do that, we will edit the 'php.ini' file to configure XDebug. The 'Loaded Configuration File' in the screenshot above tells you what 'php.ini' file is being used. For Windows, this is normally 'c:xamppapachebinphp.ini'.

Important note for Windows 7 & Vista users: As of August 2013 (XAMPP version 1.8.2), the file 'php_xdebug.dll' that is included with XAMPP now works with Windows 7 & Vista. In some earlier versions of XAMPP, the distributed version of XDebug did not work correctly. The symptom of this earlier problem was that the Apache server would stop if this version of XDebug is loaded. To check that you are running the correct version of XDebug on your system, follow these instructions on the XDebug site.

We need to edit this file to configure XDebug as follows:

  1. Find the line 'implicit_flush' and set it as follows:
  2. Find the section called '[Zend]' and comment out all of the lines by putting a semi-colon (';') at the start of each line.
  3. Find the line: zend_extension = 'c:xamppphpextphp_xdebug.dll' and uncomment it out.
  4. Find the '[XDebug]' section and uncomment out all of the lines (except for the first comment line). For Windows, it should look like the example below:

You do not need to enable XDebug profiling to use XDebug to debug Joomla code. Profiling allows you to find performance bottlenecks in your PHP code. However, enabling profiling with XDebug can slow down your system substantially, so it is not recommended unless you need it. To enable XDebug profiling, add these entries to your php.ini file.

For Windows 7 & Vista, you will use the file downloaded from the XDebug site. So the first line will be

For PHP version 5.3 or later, the '_ts' has been dropped, so the first line will read

In XAMPP 1.7.3 on Windows 7 (currently not verified/tested with prior Windows versions), XDebug may not work correctly if the path to the DLL file is in quotes. In this case, the line should be

For Linux

We will edit the php.ini file to configure XDebug. The Loaded Configuration File in your phpinfo display tells you what php.ini file is being used. For Linux, it will be something like /etc/php/7.2/apache2/php.ini. (The PHP configuration is available in the Administrator of your Website: Administrator > System > System Information > PHP Information tab.)

Edit this file to configure XDebug as follows:

  1. Find the line implicit_flush and set it as follows:
  2. Add the following lines at the end:

If using php5-xdebug on Ubuntu The xDebug Configuration detailed above can be appended to:

It should already contain the zend_extension variable and only needs the following variables added:

Xampp

Tip for users with LAN or remote servers:

Should be set to the IP address of your Eclipse workstation [LAN users] or your public IP. For example:

For Mac OS X

XAMPP for Mac OS X includes the XDebug PHP debugger, but it needs to be added to the 'php.ini' file so that XDebug runs when Apache is started. To do this, open up the php.ini file, located at '/Applications/XAMPP/xamppfiles/etc/php.ini'.

We need to edit this file to configure XDebug as follows:

  1. Find the line 'implicit_flush' and set it as follows:
  2. Add the following lines at the end:

Be sure to navigate to the directory where you targeted the extension and check to see that the file path is correct. The folders in your XAMPP installation may be named differently.

The current (as of Sept 2010) version of the XAMPP binary for OS X contains the 2.0.4 version of Xdebug which will not let you see the variable data from included files when running xdebug. You can download a newer version from http://code.activestate.com/komodo/remotedebugging/. Unzip and copy one of the xdebug.so files to /Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626. As of Oct 2, 2010 this binary is still out of date (2.1beta3 rather than the stable 2.1) but it will show the variable data appropriately.

Test XDebug Installation

Now, we need to check that XDebug is installed correctly. To do this, we need to re-start XAMPP. In Windows, we can just browse to the 'c:xampp' folder in Windows Explorer and double-click the program 'xampp-control.exe' to open the application shown below.

Press the 'Stop' button for 'Apache'. The button with then read 'Start'. Press 'Start' for Apache and wait a few seconds and the green 'Running' message will again display. Then press 'Exit' to close the application.

In Windows, if you get 'ERROR: MySQL service not started [-1]', you may be able to correct this by going to c:xamppmysql and running mysql_uninstallservice.bat followed by mysql_installservice.bat.

In Linux, to restart XAMPP execute the command

In Mac, open the 'XAMPP Control' application, stop, and then start the Apache service again.

Once XAMPP has been restarted, open a browser and navigate to 'http://localhost' to display the XAMPP welcome message (if you set XAMPP to listen to another port, you must append the port to the url; e.g.:'http://localhost:8080/'). Press the 'phpinfo()' link again to display the PHP information screen. Scroll down to the lower part of the screen. You should see a section for 'XDebug' as shown below.

Look at the settings you entered in the 'php.ini' file above. You should see these same settings in the xdebug display, as shown below.

At this point, XDebug is set up correctly.

Retrieved from 'https://docs.joomla.org/index.php?title=Edit_PHP.INI_File_for_XDebug&oldid=616716'

This section describes on how to install Xdebug.

How you install Xdebug depends on your system. There are the following possibilities:

  • Linux with a package manager such as apt, yum, or something else.
  • Linux without an Xdebug package with PECL.
  • macOSX with homebrew, through PECL.
  • Windows, with help from a wizard.
  • Unix-like operating systems, from source.

Installing on Linux #

Installing Xdebug with a package manager is often the fastest way. Depending on your distribution, run the following command:

  • Alpinelinux:
    sudo apk add php7-pecl-xdebug
  • Arch Linux:
    sudo pacman -S xdebug
  • CentOS:
    sudo yum install php-xdebug
  • CentOS (Remi Repro):
    sudo yum install php74-php-xdebug
  • Debian (9/stretch, testing/buster/bullseye/sid):
    sudo apt-get install php-xdebug
  • Fedora (32):
    sudo yum install php-xdebug
  • Fedora (Remi Repro):
    sudo yum install php74-php-xdebug
  • Gentoo:
    emerge dev-php/xdebug
  • Manjaro (20.1/Mikah):
    sudo pacman -S xdebug
  • RHEL:
    sudo yum install php-xdebug
  • RHEL (Remi Repro):
    sudo yum install php74-php-xdebug
  • SUSE (openSUSE, Enterprise):
    sudo zypper in php7-xdebug
  • Ubuntu (18.04 LTS/Bionic, 20.04 LTS/Focal):
    sudo apt-get install php-xdebug
  • Ubuntu (Ondřej Surý's PPA):
    sudo apt-get install php7.4-xdebug

Linux distributions might be providing an old and/or outdated version.If the package managerinstalls a version that is no longer supported (see Supported Versions), please installXdebug with PECL, or from sourceinstead.

Xdebug's latest version is 3.0.4.

Installing with PECL #

You can install Xdebug through PECL on Linux & macOS with Homebrew.Run:

On Apple M1 hardware, you might instead need to use:

Warning: You should ignore any prompts to add'extension=xdebug.so' tophp.ini — this will cause problems.

In some cases pecl will change the php.ini file toadd a configuration line to load Xdebug. You can check whether it did byrunning php -v. If Xdebug shows up with a version number, thanyou're all set and you can configure Xdebug's other functions, such asStep Debugging, or Profiling.

If pecl did not add the right line, skip to the Configure PHP section.

1 On macOS, you should have PHP installed with Homebrew.

Installing on Windows #

There are a few precompiled modules for Windows, they are all for the non-debugversion of PHP. You can get those at the downloadpage. Follow these instructions to get Xdebuginstalled.

Installation From Source #

Obtain #

You can download the source of the latest stable release 3.0.4.

Alternatively you can obtain Xdebug from GIT:

This will checkout the latest development version which is currently3.1.0-dev. This development branch might not always work asexpected, and may have bugs.

You can also browse the source on GitHub at https://github.com/xdebug/xdebug.

Compile #

There is a wizard available that provides youwith the correct file to download, and which paths to use.

You compile Xdebug separately from the rest of PHP. You need access to thescripts phpize and php-config. If your systemdoes not have phpize and php-config, you willneed to install the PHP development headers.

Debian users can do that with:

And RedHat and Fedora users with:

Xdebug Xampp Phpstorm Mac Os X

It is important that the source version matches the installed version as thereare slight, but important, differences between PHP versions. Once you haveaccess to phpize and php-config, take thefollowing steps:

  1. Unpack the tarball:

    tar -xzf xdebug-3.0.4.tgz

    You should notunpack the tarball inside the PHP source code tree.Xdebug is compiled separately, all by itself, as stated above.

  2. cd xdebug-3.0.4

  3. phpize

    If phpize is not in your path, please make surethat it is by expanding the PATH environment variable. Make sureyou use the phpize that belongs to the PHP version that you want to use Xdebugwith. See this FAQ entry if you're having someissues with finding which phpize to use.

  4. ./configure --enable-xdebug

  5. make

  6. make install

Configure PHP #

  1. Add the following line to php.ini:

    zend_extension=/wherever/you/put/it/xdebug

    To find out which php.ini file to modify, run a script with thefollowing:

    Alternatively, you can run php --ini on the command line.

    Note: There could be more than onephp.ini file. In many set-ups there is a different one for thecommand line (often cli/php.ini) and the web server (oftenfpm/php.ini).

    Note: If you want to use Xdebug andOPCache together, you must have the zend_extension line for Xdebugbelow the line for OPCache. Otherwise, they won't work properly together.

  2. Restart your webserver, or PHP-FPM, depending on what you areusing.

  3. Verify that Xdebug is now loaded.

    Create a PHP page that calls xdebug_info(). If you request thepage through the browser, it should show you an overview of Xdebug's settingsand log messages.

    On the command line, you can also run php -v. Xdebug and itsversion number should be present as in:

With Xdebug loaded, you can now enable individual features, such asStep Debugging, or Profiling.

Related Settings and Functions

  • stringxdebug.log =
  • integerxdebug.log_level = 7
  • stringxdebug.mode = develop
  • xdebug_info() : void

Settings

string xdebug.log = #

Configures Xdebug's log file.

Xdebug will log to this file all file creations issues, Step Debuggingconnection attempts, failures, and debug communication.

Enable this functionality by setting the value to a absolute path. Make surethat the system user that PHP runs at (such as www-data if you arerunning with Apache) can create and write to the file.

The file is opened in append-mode,and will therefore not be overwritten by default. There is no concurrencyprotection available.

The log file will include any attempt that Xdebugmakes to connect to an IDE:

It includes the opening time (2020-09-02 07:19:09.616195), theIP/Hostname and port Xdebug is trying to connect to(localhost:9003), and whether it succeeded (Connected toclient :-)). The number in brackets ([2693358]) is theProcess ID.

It includes:

[2693358]
process ID in brackets
2020-09-02 07:19:09.616195
opening time

Xdebug Phpstorm Xampp Windows

For Step Debugging:

For Profiling:

For Function Trace:

All warnings and errors are described on the Description of errors page, withdetailed instructions on how to resolve the problem, if possible. All errors are always logged throughPHP's internal logging mechanism (configured with error_login php.ini). All warnings and errors also show up in thediagnostics log that you can view by calling xdebug_info().

Step Debugger Communication

The debugging log can also log the communication between Xdebug and an IDE.This communication is in XML, and starts with the <init XMLelement:

The fileuri attribute lists the entry point of yourapplication, which can be useful to compare to breakpoint_setcommands to see if path mappings are set-up correctly.

Beyond the <init element, you will find the configuration offeatures:

And continuation commands:

You can read about DBGP - A common debugger protocol specification at its dedicated documation page.

The xdebug.log_level setting controls how much information islogged.

Note: Many Linux distributions now use systemd, whichimplements private tmp directories. This means that when PHPis run through a web server or as PHP-FPM, the /tmp directory isprefixed with something akin to:

This setting can additionally be configured through theXDEBUG_CONFIGenvironment variable.

integer xdebug.log_level = 7#

Configures which logging messages should be added to the log file.

The log file is configured with the xdebug.log setting.

The following levels are supported:

LevelNameExample
0CriticalsErrors in the configuration
1ErrorsConnection errors
3WarningsConnection warnings
5CommunicationProtocol messages
7InformationInformation while connecting
10DebugBreakpoint resolving information

Criticals, errors, and warnings always show up in thediagnostics log that you can view by calling xdebug_info().

Criticals and errors are additionally logged throughPHP's internal logging mechanism (configured with error_login php.ini).

This setting can additionally be configured through theXDEBUG_CONFIGenvironment variable.

string xdebug.mode = develop#

Phpstorm Xampp Xdebug

This setting controls which Xdebug features are enabled.

This setting can only be set in php.ini orfiles like 99-xdebug.ini that are read when a PHP process starts(directly, or through php-fpm), but not in .htaccess and.user.ini files, which are read per-request.

The following values are accepted:

off
Nothing is enabled. Xdebug does no work besides checking whetherfunctionality is enabled. Use this setting if you want close to 0overhead.
develop
Enables Development Aids including the overloaded var_dump().
coverage
Enables Code Coverage Analysis to generate code coverage reports, mainly incombination withPHPUnit.
debug
Enables Step Debugging. This can be used to step through your code while itis running, and analyse values of variables.
gcstats
Enables Garbage Collection Statistics to collect statistics about PHP's GarbageCollection Mechanism.
profile
Enables Profiling, with which you can analyse performance bottleneckswith tools like KCacheGrind.
trace
Enables the Function Trace feature, which allows you record every functioncall, including arguments, variable assignment, and return value that is madeduring a request to a file.

You can enable multiple modes at the same time by comma separating theiridentifiers as value to xdebug.mode: xdebug.mode=develop,trace.

You can also set the mode by setting the XDEBUG_MODE environmentvariable on the command-line; this will take precedence over the xdebug.mode setting, but will no change the value of the xdebug.mode setting.

Functions

Php Docker Xdebug Phpstorm

xdebug_info() : void#

This function returns an HTML page which shows diagnostic information. It is analogous to PHP's phpinfo() function.

The HTML output includes which mode is active, what the settings are, and diagnostic information in case there are problems with debugging connections, opening of files, etc.

Xampp Xdebug Phpstorm

Each warning and error in the diagnostics log also links through to the Description of errors documentation page.