Setting Up XDebug for PHP Debugging on Linux

Blog
Spread the love

XDebug is a popular code debugging tool for PHP that seamlessly integrates with PHPStorm IDE. In this guide, we will walk you through the steps to set up XDebug on your Linux development machines.

Please follow the below steps:

Step 1: Install XDebug 3

Reference: https://xdebug.org/docs/install#linux

Assuming the currently installed PHP version is 7.4.

Run below command to install xdebug:

Step 2: Configure php.ini

Reference: https://xdebug.org/docs/install#configure-php

Configure the XDebug module in the php.ini file to load and enable it.

Run below command to get the path of xdebug.so file:

>locate xdebug.so

Open php.ini using sudo gedit /etc/php/7.4/apache2/php.ini and paste the code below at the end of the file.

Now, need to restart the apache server. To restart the Apache web server, execute the following command in your terminal:

Step 3: Verify

Verify Xdebug installation by doing any of the following:

  1. In the command line, run the following command:

> php –version

extention_2023

Step 3.1

Typically you can create a new 99-xdebug.ini file inside the /etc/php/7.4/cli/conf.d/ directory, if it doesn’t exist already, which will get loaded automatically by the main php.ini file.

After the configuration, restart the PHP service.

Step 3.2 Create a php file containing the following code:

extention_2023

Step 4: Configure PHPStorm

4.1: PHPStorm Project Server

Configure the server path for the project so that PHPStorm knows which
files to listen to.

extention_2023

4.2 PHP CLI Interpreter

Configure the correct PHP interpreter for your project and make sure
PHPStorm can identify your XDebug configuration.

extention_2023

4.3: Configure Debug Tool

Configure the correct debug tool that you want to use with your IDE. In
our case, that would be XDdebug.

extention_2023

4.4 Start Listening

When you are ready to start the debugging, make sure that you have
turned the switch to listen to the XDebug requests to your IDE.

Listen Status: off

extention_2023

Listen Status: on

extention_2023

Reference: https://www.jetbrains.com/help/phpstorm/2021.2/configuringxdebug.html

Now you should be able to add the breakpoints to your PHP code, wherever
necessary, in your IDE and start your debugging process in an efficient way with the
help of Xdebug Helper chrome extension.

extention_2023

Happy Coding!!

bluethinkinc_blog

bluethinkinc_blog

2023-10-06

0

Leave a Reply

Your email address will not be published. Required fields are marked *

Find More Blogs

Proxy Design Pattern and Requisition List in Magento 2

Spread the love Requisition List in Magento 2 Requisition

Google Ads Conversion Tracking Through Magento Platform:

Spread the love Google Ads Conversion Tracking Through

Object Pool Pattern in Magento2

Spread the love What is Object Pool Pattern in Magento 2 An

JENKINS

Spread the love JENKINS Introduction and Installation

Virtual Type and Type

Spread the love Virtual type is one of the most common

Customize the length of Input field

Spread the love Sometimes we need to change the limit the

How to Add Custom Tab on Admin Dashboard and Count Website Total Visitor in Magento 2?

Spread the love In this blog we’ll see How to Add Custom

How to Add Sign Out Tab in Customer Account in Magento 2?

Spread the love In this blog we’ll see How to Add

How to create custom tab in product detail page in magento 2?

Spread the love In this blog we’ll see how to add

Understanding and Implementing CORS & CSRF

Spread the love What is security? The world has become more

bluethinkinc Blogs