PHP debugger?

I am familiar in the past with the Turbo Pascal IDE and debugger. I really liked how it worked. Then I moved to Linux and PHP. I’ve tried many times installing things called a debugger, and it mostly just sat there. I think once when I was still on Windows, I found something which showed the variable’s values, but wouldn’t let you change them. I can’t really imagine that someone went to a lot of work to create something called a debugger which does nothing useful. So maybe I need help in installation and setup.

I would like something which allows you to single step through PHP code, lets you change the values, and allows you to see the web page result as it steps through the lines. It would also be nice to set breakpoints. I use Kate, so an added bonus would be to have it integrate with it. I understand you can purchase a Zend IDE and debugger. Does anything like that exist in open source software? And if so, what are the steps in setting it up and any other necessary packages. I’m really getting tired of my echo statements, even though I’ve expanded my debug_backtrace use.

I think you’re after Zend Studio and related products (Zend Server):

https://en.wikipedia.org/wiki/Zend_Studio


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…

You may or may not have noticed that debuggers are often tightly integrated with the IDE you’re using, so in general you should look for the recommended IDE for your chosen development language before considering debuggers (if you’d even need to).

So, Webstorm is probably one of, if not <the> most popular IDE for developing websites using just about any commonly used language. The following link is to the version of Webstorm with the PHP plugin automatically included. Their licensing generally is about $100 US for most individual developers, but free to anyone who contributes to a FOSS project (hint, hint).
https://www.jetbrains.com/phpstorm/

Also, although I don’t use Eclipse for coding sites using “only” PHP because to me eclipse is far too big and unnecessary for simpler projects(but I’d strongly consider for an extremely large, complex app), it’s worth noting what eclipse installs for various tasks, because that’s essentially what eclipse does… It provides the bigger environment but points to smaller utilities for individual functionality. So, based on the following article I’d investigate Xdebug.
https://wiki.eclipse.org/Debugging_using_XDebug

HTH,
TSU

Looking at Zend Studio and PHPStorm, I see they’re something like $100 every year. So I looked at Eclipse. There’s so much I don’t understand, I don’t really know where to begin to ask. As with Zend Studio talking about Zend Server, which I don’t know if I need both. But with Eclipse, it talks about xdebug, PHPEclipse, EclipsePDT, …?

Zend talks about the open source EclipsePDT and I think they have something to do with Eclipse. Then I search and find:
“PHP Development Tools (PDT) is a language IDE plugin for the Eclipse platform and the open source project that develops it.”
I don’t really understand what that means. Does that mean you need Eclipse AND this plugin to work?
But, “Eclipse is an integrated development environment (IDE) used in computer programming, and is the most widely used Java IDE.”
Further reading shows, "but it may also be used to develop applications in other programming languages through the use of plugins, "
So I must need both, right?

Looking at the Zend site comparing Zend Studio and Eclipse PDT, the studio has PHP Executable Debugger and Integrated PHP Debugging while the PDT only has Web Server / Remote Debugging. I don’t understand what that means, whether PDT would work for me or I need the other two.

Then there’s, “PHPEclipse is a PHP development plugin for the Eclipse IDE Framework.”
Is this an alternative to the PDT, that is, one or the other?

I see some other things (“things” for lack of knowing what you would call them) saying for example, Aptana an “(IDE) for building web applications. Based on Eclipse,”. Does this mean I need Eclipse in addition to this IDE or is it in place of? I’m having trouble with the words as to me, “based on” or PHPEclipse “built on the Eclipse framework” could mean it was a fork or otherwise taken from a concept, or it could mean it requires it. To complicate things, I now read that Aptana can be downloaded as a standalone or as a plugin for Eclipse. And that additional plugins allow it to support PHP. (A plugin to a plugin to Eclipse?!) So why would you choose one over another? If you already have Eclipse for another language, I suppose adding a plugin would be simpler. But if I have Eclipse, why not just add the PDT plugin and forget the Aptana plugin. “In the 2.0 version, Aptana did not provide its own PHP plugin, but transferred development efforts to the PDT project.” Am I confused or what?

Anyway, sounds like I need Eclipse AND a plugin if I go that direction?

I have something on my system installed called php5-xdebug. I also see available php5-ZendFramework on OpenSUSE. Is that all I would need for xdebug or are those something like links to link php to them? I have zend_extension = “/usr/lib64/php5/extensions/xdebug.so” and it does exist there.

By the way, the article about using XDebug showed I didn’t have xdebug.remote_enable = On. I had an xdebug.ini-new in the folder. Don’t know if that would have caused problems in my past attempts or I never got to the point where it would.

You can think of Eclipse as a “Development Platform.”
There is the core app, and then there are is an abundance of different plugins, extensions and individual utilities which you can “plug in,” switch around, re-configure and more. There also several different ways that different frameworks can be installed.

Yes, the eclipse ecosystem is very big and complicated, which is why I personally use it only when doing something extremely complex, and some very complex projects find that Eclipse is maybe the only tool that can support them because of its capabilities.

But, it doesn’t have to be so difficult to just get started, thankfully the Eclipse community recognized that all those choices and architectural complexity can be intimidating to new Users… So, they’ve simplified the initial install by offering common package combinations.

Go to http://eclipse.org.
Click on the “Other Package Downloads” link under the Downloads button.
Scroll down the page until you see “Eclipse for PHP Developers” and click on the 64-bit link, and your eclipse complete with PHP components will install.

I haven’t installed any new version of Eclipse for a few years now, but you should know

  • When you install from Eclipse.org, unlike the packaged Eclipse from openSUSE, eclipse will be downloaded and uncompressed into a location of your choosing. I recommend a root directory location, eg a subdirectory of /opt/. Note that will generally mean that default access to this location will require elevated permissions, but in general that shouldn’t be an issue… There’s lots of stuff done while developing that requires elevated permissions anyway so just require elevated permissions to access eclipse in the first place.
  • I don’t know if you still need to set Java environment variables, if so then I recommend creating a /etc/profile.local file holding your environment statements.
  • Since the eclipse file tree is completely self-contained, if you ever want to delete the eclipse application, just delete the file tree.

As for running XDebug standalone, I don’t know it may be possible.
As I described, Eclipse accepts and utilizes many standalone utilities for different functionality, I mentioned Eclipse both as an IDE and as a recommendation for a debugger.

HTH,
TSU

Ok, I have Eclipse installed. Thanks for telling me about the “other package downloads”. I never would have even thought of looking there because, since I wanted Eclipse, I wouldn’t want to download some “other package”. I guess if they had labeled it something like “programming specific packages” or something of the like, I might have looked.

I extracted it into /opt directory and don’t think I had any trouble with permissions. It loads, I can write programs, and run them. I tried to keep things simple to test it. I wrote a simple 3 line program with two echo statements and a variable assignment. I set a breakpoint at the first echo statement. I click debug as CLI Application, thinking this will eliminate any server setup issues. It runs straight through printing both echo statements.

There’s so many preference setups I don’t know if I have it correct. I can’t find any tutorial on the PHP configurations for the CLI interface. I look at the debug configurations for PHP CLI Application and on the Debugger tab, when I click configure, and then select yet another debugger tab (this gets confusing), and then select XDebug, it says the extension is not installed. But yet it is, I think… …

Now I see something on the PHP Executable tab about use default php.ini configuration. I check that and try it and it halts at the first statement! So I don’t know why when I specify the path in the preference setup it doesn’t work, but yet the system default .ini works? Maybe it doesn’t really matter at this point. I’m using 13.1 and in the /etc/php5 directory, there is the apache2 and cli directories with their php.ini. There is also a conf.d directory with the xdebug.ini which I assume is loaded somehow. I had tried setting the path for php.ini to be actually the xdebug.ini, but it still said no extension. Maybe “system default” has the two ini’s merged together somewhere else that Eclipse is using?

Anyway, now my question is, can I change the value of the variable? It shows my “$a”, but I see nothing in how to change the value to something else.

A Google search using the keywords “php eclipse setup tutorial”

Returns a number of videos, an eclipse PDF document that should describe how to use the debugger plus additional debugger tutorials.

HTH,
TSU

Thanks. I was looking for “tutorials”, but after doing a web search found it listed as “article”. Thank you for your help. I briefly searched and found where to change variable values. Lots of things to set up, and find even, in Eclipse. Now I see what “big and complicated” means! Now to just try to understand the reading material. Thanks for the help in getting me started.