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

How to Add a Custom Tab to the Customer Order Detail Page in Magento 2

Spread the love Adding a custom tab to the Order Detail

Exception Handling in Java

Spread the love Introduction – Exception:An unwanted

How to add custom less file in Magento2

Spread the love Source files *.css included into layout

Spring Boot Microservices

Spread the love Microservices architecture has become

Implementation of WireMock for better testing

Spread the love WireMock is a flexible and powerful tool

Magento 2: How to selected default option in configurable options?

Spread the love Configurable products in Magento 2 allow

How To Implement Simple JWT Authentication in Django Rest Framework

Spread the love We’ll learn how to use simple JWT

Optimizing Search: Integrating Elasticsearch in Django Applications

Spread the love What is Elasticsearch? Elasticsearch is a

How to create Customer Segments

Spread the love In Magento 2, “customer

Proxy Design Pattern and Requisition List in Magento 2

Spread the love Requisition List in Magento 2 Requisition

bluethinkinc Blogs