Search code examples
phpdebuggingsublimetext3phalcon

Is it possible to Debug with Phalcon PHP?


Is it possible to debug Phalcon PHP?

I'm using Sublime 3 editor but am willing to use any editor if debugging is possible.

I found a similar question on Stack Overflow but the only answer was a sales pitch about how great Phalcon is.

Updated: I'm updating this question after the fact. I learned that debugging a Phalcon application is no different than debugging a PHP application except that you cannot debug the actual Phalcon code. I didn't think it was possible to debug at all so my question might have been misleading to other developers that were new to both PHP and Phalcon at the same time.


Solution

  • I'm assuming that you want to debug your PHP code, not Phalcon extension. If you mean debugging Phalcon framework itself you should install Zephir for code modifying and use gdb to run php command (at least on linux, not sure what about other systems).

    Standard var_dump(), echo, printf and die

    It works well with all the phalcon objects, just print out variables you want to debug using var_dump() (or other output functions) and use die() before execution your view code. If view part of application get executed will most likely replace your debug printings.

    Alternatively you can also pass your variables to view part of your application and just simply use <?php var_dump($variable)?> or if you're using volt just {{dump(variable)}}.

    Using XDebug Remote

    This is the way I personally like the most. Yes, XDebug Remote works great with Phalcon. Personally I use NetBeans but you can use other IDE's as well. There are many tutorials for configuring all the popular IDEs so I'm not going to write it again. Note that Phalcon team suggests to use XDebug 2.2.3 or greater for better compatibility.

    how to configure XDebug on PHP Storm

    how to configure XDebug on NetBeans

    how to configure XDebug on Sublime 3

    You can read more about debuging Phalcon in Phalcon's Documentation