📜 ⬆️ ⬇️

Eclipse, chanterelle and xdebug

Long and extensive introduction



Shift work. A job change is always stress, no matter how trendy the pepper is.
in the previous place you were. After years of sweet life again, it is necessary
to strain, to understand the heap of code written without you,
to be surprised not by you to make decisions and to be horrified by them is sometimes not easy
unnecessary complexity.

We all know how the fan picks up from working in
spaghetti code to add or remove something. However coming
We are not choosing the first time task for a new place. With
my reluctance to engage in the analysis of the old bad code I started
fight in several directions:
')
1. Psychological: I try not to get angry at the one who wrote it, but
I just understand how it works. Do not believe in the area
temples from this becomes unusually easy, the face becomes more
friendly and the code looks more understandable.

2. Organizational: Apply a short squeeze from GTD: a) collect all
b) reread what you have gathered c) do it. This direction has
also the technical side, but not about it today. The main thing with
rereading (clause b) not “returning” the case without accepting any
intelligible decisions on their further fate. By the word "deal with it
later, this is quite a clear decision.

3. Technical: That's about this direction of my self-instrument you
you can finally read after so long and, as usual,
It turns out, a lengthy entry.

Postsupplement



Do not rush to conclusions, I was not mistaken with the title of the article. PHP is a paradoxical technology. On it sometimes they write probably the most
incomprehensible code in the world. The scope of this very "already written" code
present is not possible. Programmers, too, is not enough. And what do you imagine
think - all this infantry basically still debug their programs
using the good old echo-debugging. This one has
a disadvantage that complicates my life, after each session of such
debugging, in order to remove the results of my activity, I revert and
if you need to hold a similar debag session after some time all
need to start from the beginning. What is there to talk about cases when without
beloved die () just can not do.

On Habré this tool was already described more than once. Also at least
its installation was described twice and even XDebug was mentioned once
helper. However, a simple setup guide all together in one
I did not find the document. Because without bringing anything new I’ll just become
so an integrator of several documents and articles in order to facilitate
life to all who need it, and their Internet providers.

Install XDebug



What under windows, what under unix configuration part in general cases
the same:

zend_extension_ts=full_path_to_xdebug.(so|dll)
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_port=9000
xdebug.remote_host=127.0.0.1
xdebug.idekey=eclipse

And you should not care about these parameters, as shown
practice (3 installations on win, mac and ubuntu) it all works without
changes to completely standard installations of these systems. Is that there
note about mac os x - xdebug lifted from the ports did not want to work
with apache2 + php installed in the same way. Because there he was
assembled handles one to one as described here
xdebug.org/docs/install in the Compiling section.

What is not less important:


If you use apache2 and php as a module, then you need to download
hence xdebug.org/download.php threaded the build, otherwise (apache
1.3 + php as module or php as CGI) non-threaded build. That's all that
caused a complication with the installation in my case.

As usual we restart apache and check php --re xdebug - if
everything is in order - you will understand it.

Install XDebug helper



It’s as simple as putting the usual firefox extension:
https://addons.mozilla.org/en-US/firefox/addon/3960

Configure eclipse PDT



Feel free to go to Window / Preferences (for Mac Cmd +,) in the filter we drive in
Installed Debuggers. Choose in the results (who knows how)
PHP / Debug / Installed Debuggers. And we are going to set up XDebug:
the only thing you need to do is install Accept remote session
(JIT) field at least in localhost or in any that is more relevant to you
except off.

The final



This is actually all that needs to be done. Then one big fan in
work. Open your product in firefox, click on the xdebug icon
helper and do something with your product (once). Now
switch to PDT and wonder there should be a window offering you
switch to php debug perspective. And then the matter is small - or
F6, (F6) and sometimes F5 or set breakpoints and walk faster. At all
Speaking is not tricky.

Possible problems


(1) Sometimes a debug session does not start.

Solved in three steps: 1 clean XDEBUG cookies from your development
domain and if it does not help restart ff and further if everything is
still does not work - restart eclipse (by the way, I have
rarely happens)

(2) Sometimes a debug session starts and immediately stops with a drop.
window in eclipse about unexpected session stopping

It is necessary to remove all the Expressions in the same window. It happens
when in the previous session you used the Watch function to
would see the value of some variable or expression.

Final chord



Please note that all that is proposed to the setting in this article
absolutely free and free. I wish you all that all that you
really needed to work was either free or affordable;)

Source: https://habr.com/ru/post/69954/


All Articles