Configure Xdebug In Sublime Text Editor For Magento Project

Updated: Aug 20, 2020

This article describe the step by step process of configure xdebug in sublime text editor for magento project.

1. Install Sublime Text Editor

If you already have sublime text editor please skip this step

For Sublime-Text-2:

sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo apt-get update
sudo apt-get install sublime-text

For Sublime-Text-3:

sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install sublime-text-installer

2. Install Xdebug

Please run the below command to find the right xdebug package to install

sudo apt-cache search xdebug

It should return the information like below

php-xdebug – Xdebug Module for PHP

so we need to install php-xdebug (it may be vary like php5.6-xdebug, php7-xdebug….)

sudo apt-get install php-xdebug

Add the below contents at the end of /etc/php/your_version/apache2/php.ini

# Added for xdebug
zend_extension="/usr/lib/php/20151012/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=www.chennaifruit.com
xdebug.remote_port=9000

Restart the apache

sudo service apache2 restart

3. Install Xdebug client in Sublime

Sublime -> View -> Show Console


install xdebug client

Please paste the below content as per your sublime version in cosole like above screen shot then hit ENTER

Subl3

import urllib.request,os,hashlib; h = 'df21e130d211cfc94d9b0905775a7c0f' + '1e3d39e33b79698005270310898eea76'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)

subl2

import urllib2,os,hashlib; h = 'df21e130d211cfc94d9b0905775a7c0f' + '1e3d39e33b79698005270310898eea76'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler()) ); by = urllib2.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), 'wb' ).write(by) if dh == h else None; print('Error validating download (got %s instead of %s), please try manual install' % (dh, h) if dh != h else 'Please restart Sublime Text to finish installation')

Open up Command Pallete (Ctrl+Shift+P Windows/Linux; Cmd+Shift+P Mac OS users)


command pallet

Start typing install. Press Enter when Package Control: Install Package appears


package control

Type XDebug and choose XDebug Client


xdebug client

Restart sublime

4. Create Project

Open Magento 2 folder in Sublime Text after that go to Project->Save Project As and save it within the root of your magento application as mage2.sublime-project.


create project

Then edit the sublime project (mage2.sublime-project) file content like below

{
	"folders":
	[
		{
			"path": "/var/www/html/magento-root"
		}
	],
	"settings": 
	{
	    "xdebug": 
	    {
	         "url": "http://magento.host.name/"
	    }
  	}
}

That’s it!

When you have at least one breakpoint set, you can go to Tools->XDebug->Start Debugging (Launch Browser) and have fun


start debug

debug output

#magento #magento2 #sublime #xdebug

17 views0 comments

Recent Posts

See All

Magento 2 CMS block with the same ID already exists

I have seen the below error when I open cms block grid something went wrong with processing the default view and we have restored the filter to its original state. I found the below log in the excepti

How to generate bearer token - Magento 2 REST API

We can generate the admin bearer token using the below command. Please run the below command in the terminal to generate a token. curl -XPOST -H 'Content-Type: application/json' http://www.domain.com/

Magento 2 script tag and available options in layout xml

We can add a script via layout XML file in Magento 2. The below format will stop the HTML parse until js downloaded and executed. <script src="Bilal_Usean/js/sample.min.js" /> The below format will st