How to configure xdebug error messages to open file in Kate editor on Ubuntu

By | May 25, 2021

Xdebug is a powerful debugging and profiling tool for php that allows you to find and fix errors faster by showing the entire stack trace and source code file and line number.

If you want your php development to be error free you should use something like xdebug right from the beginning.

A very useful trick is to configure xdebug to show errors with hyperlinks to the source code file that can open directly in a text editor of your choice.

Not all text editors support this feature. However on Ubuntu, the kate text editor supports opening files via urls from browsers.

Read to below to learn how.

Configure Xdebug error messages to open file in Kate

Modify the php module configuration file xdebug.ini file which is located in the mods-available directory.

On my system for example its located at:

/etc/php/7.4/mods-available/xdebug.ini

Edit and add the following line to the configuration file:

xdebug.file_link_format="kate://open/?url=file://%f&line=%l"

The file would look like this:

$ cat /etc/php/7.4/mods-available/xdebug.ini
zend_extension=xdebug.so
# our modifications
xdebug.file_link_format="kate://open/?url=file://%f&line=%l"

The chrome browser compatible line to invoke Kate text editor is the following. It takes the path to the file and the
line number:

kate://open/?url=file://%f&line=%l

Other useful settings

There are a couple of more useful settings in xdebug that can be used to make development more bug-free.

The scream setting will disable error suppression using the "@" operator and show all errors.

This is useful for catch all possible errors that are hidden anywhere in your application.

xdebug.scream = 1

The halt_level setting determines whether notices and warnings are reported as errors.

xdebug.halt_level=E_WARNING|E_NOTICE|E_USER_WARNING|E_USER_NOTICE

Links and Resources

To learn more about xdebug configuration parameters check the documentation at:

https://xdebug.org/docs/all_settings https://xdebug.org/docs/upgrade_guide
About Silver Moon

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected].

Leave a Reply

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