Configure Xdebug In Sublime Text Editor For Magento Project
- Bilal Malik
- Jun 21, 2017
- 2 min read
Updated: Aug 21, 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

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)

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

Type XDebug and choose 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.

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


Comentarios