Skip to content

Instantly share code, notes, and snippets.

@guilhermelinhares
Last active February 8, 2023 23:42
Show Gist options
  • Save guilhermelinhares/4e280c125c194c8e47ec7f60d0561e4a to your computer and use it in GitHub Desktop.
Save guilhermelinhares/4e280c125c194c8e47ec7f60d0561e4a to your computer and use it in GitHub Desktop.
Install Xdebug Localhot | Phpstorm | Vscode

Install + Configure Xdebug 3

Method to install xdebug 3. Homolog in Ubuntu 22.04 , AlmaLinux 8.7

Php Versions:

  • 7.4
  • 8.0
  • 8.1

Getting Started

Dependencies

  • Php

Installing

  • Link install xdebug
  • Link chrome extensions xdebug

Configure Php CLI

Before begin initialize a setup xdebug you need check the verion php.

  • Check the version php
sudo php -version
Install Xdebug 3 + Php Versions + PhpCGI(Ubuntu)
  • Install php 7.4
sudo apt-get update -y
sudo apt-get install php-xdebug php7.4-xdebug php7.4 php7.4-cgi
  • Install php 8.0
sudo apt-get update -y
sudo apt-get install php-xdebug php8.0-xdebug php8.0 php8.0-cgi
  • Install php 8.1
sudo apt-get update -y
sudo apt-get install php-xdebug php8.1-xdebug php8.1 php8.1-cgi
Install Xdebug 3 + Php Versions + PhpCGI(Rhel)
  • Pack-Remi Php 8.0
dnf config-manager --set-enabled remi
dnf -y module reset php
dnf -y module enable php:remi-8.0
yum -y upgrade php*
  • Change Version PHP
sudo update-alternatives --config php
sudo update-alternatives --config phar
sudo update-alternatives --config phar.phar

image

Configure the xdebug

  • Configure extension xdebug.ini for environment Localhost

Check the location the xdebug.ini

sudo php -i |grep xdebug.ini
  • Edit the xdebug.ini file
zend_extension=xdebug
xdebug.remote_enable = 1
xdebug.client_port=9004
xdebug.client_host=127.0.0.1
xdebug.show_error_trace = 1
xdebug.start_with_request=yes
xdebug.mode=debug

For phpstorm you need put in the file

xdebug.idekey=PHPSTORM

Steps configure PhpStorm IDE

  1. Settings(ctrl+alt+s)

  2. PHP

    1. Set version PHP in -> PHP Language Level image
    2. Create php version in -> CLI Interpreter image image
  3. Debug

    1. Set a port 9004 in Debug Port image

Steps configure Vscode IDE

  1. Install extension - Extension ID -> xdebug.php-debug image

  2. Vscode settings

  3. image

  4. Edit settings.json 1. Insert a port 9004 in array "php.debug.port": [] image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment