Cli Xdebug



This topic describes how to install Xdebug either on Zend Studio PHP executables or a local PHP Web server.

From Xdebug 2 to Xdebug 3, the naming of config settings has changed. The above settings are the Xdebug settings for Xdebug 3.x. If you are running Xdebug 2.x, you have to either update or use the equivalent Xdebug 2.x settings. Xdebug and CLI in Docker. Want to run a CLI command on Docker while debugging it with XDebug in an IDE like PHPStorm? Then you need to have your environment in order. First, create the path mappings in PHPStorm by creating a server in Settings / Preferences Languages & Frameworks PHP Servers. Command line interface (CLI) With the steps explained above, we are already able to tell what the xdebug.remoteconnectback ip should be and how to apply it. Once you have set that up, you can start debugging with Xdebug via the container’s CLI, like so (assuming your container holds your app on /app).

Note:

Xdebug cannot be used with PHP 5.5 executable (CLI and CGI) on Windows and Mac.

Installing Xdebug on a Zend Studio PHP Executable

This procedure describes how to install Xdebug on a Zend Studio PHP Executable. If you want to use Xdebug for debugging on a Web server, you will need to install Xdebug on your Web server as well. See Installing Xdebug on a PHP Web Server below for more details.

To install Xdebug:

  1. Download Xdebug from Xdebug Downloads page. To find out which version of the extension to download, click here.
  2. Disable the Zend Debugger:
    1. Open the 'php.ini' file of your PHP:

    <Zend_Studio_install_dir>pluginscom.zend.php.debug.debugger.win32.x86_10.6.0.v20140121-1240resourcesphp.ini

    1. Add a semi-colon ';' before 'zend_extension=...' as follows:

    ;zend_extension='C:Program Files (x86)ZendZend Studio 10.6.0pluginscom.zend.php.debug.debugger.win32.x86_10.6.0.v20140123-1837resourcesphp53ZendDebugger.dll'

  1. Move the downloaded file to your Zend Studio's installation files:

<Zend_Studio_install_dir>pluginscom.zend.php.debug.debugger.win32.x86_10.6.0.v20140121-1240resourcesphp_version

  1. Back in the 'php.ini' file, add the path to the Xdebug extension.

For example:

Linux and Mac OS: zend_extension='/usr/local/php/modules/xdebug.so'

Windows: zend_extension='<path to .dll file>'

  1. Add the following line:

xdebug.remote_enable=true

  1. Save your changes, and restart your Web server.

Note:

To verify that Xdebug was installed correctly, call the “php --re xdebug” command. If the output is different than 'Exception: Extension xdebug does not exist', the extension is installed correctly.

Once installed, you can now configure Xdebug in Zend Studio to begin debugging.

Xdebug cli not workingXdebug cli config

Installing Xdebug on a PHP Web Server

This procedure describes how to install Xdebug on a PHP Web server.

To install Xdebug:

  1. Download Xdebug from Xdebug Downloads page. To find out which version of the extension to download, click here.
  2. If you are using Zend Server, disable the Zend Debugger (If not, skip to step 3).
    1. Access the Zend Server UI (http://<server_ip>:10081/ZendServer).
    2. Go to the Configurations | Components page.
    3. Select the Zend Debugger from the components list, and click Disable in the Action bar.
    4. Restart Zend Server.

  3. Move the downloaded file to your Web server's installation files.

If you are using Zend Server:

<Zend_Server_install_dir>libphpext

  1. Open your Web server's 'php.ini' file.

If you are using Zend Server:

<Zend_Server_install_dir>etcphp.ini

  1. Back in the 'php.ini' file, add the path to the Xdebug extension.
    For example:

Linux and Mac OS: zend_extension='/usr/local/php/modules/xdebug.so'

Windows: zend_extension='<path to .dll file>'

  1. Add the following line:

xdebug.remote_enable=true

  1. Save your changes, and restart your Web server.

Note:

To verify that Xdebug was installed correctly, call the “php --re xdebug” command. If the output is different than 'Exception: Extension xdebug does not exist', the extension is installed correctly.

Once installed, you can now configure Xdebug in Zend Studio to begin debugging.

Copyright © 2017Rogue Wave Software

From Joomla! Documentation

  • 1Edit PHP.INI File for XDebug
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:

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.

Clidebugger

Cli

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.

Command Line Xdebug

In Linux, to restart XAMPP execute the command

Xdebug Cli Vscode

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.

Xdebug Cli Not Working

At this point, XDebug is set up correctly.

Xdebug Cli Disable

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