Kdevelop for Web Developers

Basically, this is a follow-up on my Article about Quanta/Gubed several years ago. However, as Quanta is long dead now, unfortunately, there is clearly a need for a replacement, especially one that integrates well with KDE.

And no, I’m not going to bash established IDEs like eclipse, netbeans etc. - just a simple word: I personnaly don’t like dinosaurs . So, what’s left ?
Short answer:  Kdevelop  .
This, although commonly known as superior IDE for C++ development, especially under KDE, has come a long way and through its flexible plugin-structure, it is nowadays also a feasible alternative for other tasks, including development for scripting languages like php and python.
This article will focus on the php side, as this is what I’m using it for .
So, lets start with the basic features.

  • Project handling: Projects can be created from inside Kdevelop, there are templates for all kinds of projects, including php. On the other hand, it is also possible to simply open an existing directory with source files - voila, thats the new project.
  • Editing: Easy enough, as Kdevelop uses Kate as its default source code editor, which is just awesome, especally with php-documentation installed (this is usually done through  standard package managers). Syntax highlighting, code folding, online help, all is there.
But, what makes up a real, full-featured IDE ? - the integration of a powerful debugger, of course.
For C/C++, it is well-known that Kdevelop integrates gdb very well, with everything needed is available as binary packages for virtually every distro. Nowadays, there is, fortunately, xdebug for php - integrated with Kdevelop through a plugin. So, lets focuse on this one. These are the prerequisites:
  • kdevelop in a recent version (I'm using 4.5.1 on Kubuntu 12.04)
  • kdevelop-php (php-plugin)
  • kdevelop-php-docs (optional, recommended)
  • kdevelop-l10n (localisation, recommended)
  • kdevelop-php-l10n (localisation, recommended)
  • php5-xdebug
then, unfortunately not commonly available as binary packages:
  • kdev-xdebug
  • kdev-php-formatter (optional)
Everything mentioned in the 1st list is usually available through the package manager of most distros, I will not further explain how to get these installed, but rather outline the steps needed to get the plugins installed that have to be built from source (usually).
First step is to get everything which is needed to build KDE source packages, namely git, g++, cmake, kde development librarys and so on. For most distros, a good start is usually [this](http://techbase.kde.org/Getting_Started/Build/Distributions) . Then, general advice on how to build KDE packages from source is also on [KDE techbase](http://techbase.kde.org/Development/Tutorials/Building_An_Existing_Application) . A short howto (slightly outdated, e.g. executescript and executebrowser are now parts of kdevelop base, no more extra install needed) for building kdev-xdebug is available on [Niko Sam's site](http://nikosams.blogspot.de/2010/02/kdevelop-xdebug-php-debugger.html) . This is also what I used as a a starting point. But, as this howto is a bit short (not every step obvious for n00b's ), and, as not everything went quite well (as usual ) I decided to outline here a bit more in detail what I did, what went wrong and how I got around the problems to get it to work, finally. Maybe this will also help others... So, let's start:
  1. get the source: mkdir ~/kdevplugins (or any other suitable location) cd ~/kdevplugins git clone git://anongit.kde.org/kdev-xdebug cd kdev-xdebug git branch -a (this shows which branches are there, choose the correct one: 1.5 is for kdevelop 4.5.x, 1.4 for kdevelop 4.4.x) git checkout remotes/origin/1.5 (use correct branch here, or master for the latest and greatest)
  2. build: mkdir build && cd build cmake .. (in case cmake complains about missing dependencies, install these and start over) make
  3. install: sudo make install kbuildsycoca4
  4. check kdevelop plugins if kdev-xdebug is there:![](php_xdebug_modules.png)
  5. enjoy :D![](php_xdebug_demo.png)
Ok, at least, that's the way it is supposed to work ;-)
For me, there was the problem, that although every step obove (except 5.) succeeded, I was not able to get the debugger running, see [this thread](http://mail.kde.org/pipermail/kdevelop/2014-January/018199.html) in the kdevelop mailinglist. After some investigation, and thanks to the help of Niko, the xdebug plugin developer, I succeeded to get it to run, heureka. The culprit was the installed php5-fpm extension (which makes no sense, IMHO, on a desktop computer) which blocked port 9000 on localhost, which in turn is needed by xdebug. As can be seen on the list, Niko has meanwhile added a comprehensive error message in the plugin (git master) in case anyone else is affected by this problem.

Conclusion: finally, the plugin works as expected, an invaluable help when developing php code that is a bit more sophisticated than just calling phpinfo() :D So, no need anymore for Quanta/Gubed, in this respect.
And not to forget, there are meanwhile other php/web dev related kdevelop plugins, namely:

  • kdev-upload
  • kdev-php-formatter
  • kdev-css
  • kdev-xml
which are still experimental, but promise to even further qualify Kdevelop as a real replacement for good old Quanta. (From these mentioned, I'm using kdev-upload on a regular basis, and it works so far as expected, just not deleting files on the server which have been removed locally, but that's a minor issue, IMHO).

Additional note: a simple debian package (built with checkinstall, so no real dependency checks..) can be found here:  kdev-xdebug_20140201-1_i386.deb  - simply download and install with ‘sudo dpkg –install kdev-xdebug_20140201-1_i386.deb’.
Be warned: this is only tested on Kubuntu 12.04 with kdevelop 4.5.1 installed in default locations, including mentioned php stuff !

Related Articles