What is the procedure for debugging a "runstack", Javascript or Php via the Aptana browser or IDE?

Asked

Viewed 265 times

6

When we develop a code, it runs on a stack of instructions.

Is there any way, through the browser or an IDE, where we can track step by step the processing of the code, and see to what extent it was executed or stopped due to some error ?

I know that each language offers methods for error handling, however this method is part of the execution stack, this put, my doubt excludes as an option the methods through the code itself.

  • Each language has its own methodology, Windows want to debug what? html js php?

  • php, ajax, js basically

2 answers

3


For javascript use the Chrome debugger. Just press F12 and he will appear. Go on the option console and make your debauchery.

For PHP it’s not that simple but it’s easy. First of all I wanted to comment on the IDE. There are many on the market. Free or not and each programmer has their own preference. I use Netbeans. It is free and complete. No many bureaucracies to install extensions including debuggers. Here you can do the download of the version that suits you.

To run a debtor in an IDE you need to:

  1. Configure the deboner or debugger in the php startup file, the php.ini.
  2. Configure the IDE to accept the debtor already installed. NOTE: If you use netbeans, this step is not necessary as it recognizes the configuration within the php.ini automatically.

Regardless of the IDE used you will have to configure Xdebug on php.ini and that is the most laborious part. The second part, of IDE Aptana I will pass the link with step by step.

  1. Create a project with any name and then a page containing phpinfo(); only;
  2. Open the browser that displays the information from phpinfo and copy everything (crtl+a next crtl+c)
  3. Go to that link of Xdebug and paste its contents into the appropriate space and press the button Analyse my phpinfo output. See photo below: inserir a descrição da imagem aqui
  4. This tool will find the dll extata for your php versatile. See the photo below: inserir a descrição da imagem aqui
  5. Click on the file dll offered and download.
  6. Find the folder where PHP extensions are located (ext). In some installations it is directly inside the PHP type directory (php>ext) in others it is inside the bin folder (php>bin>ext). Note that the tool showed you in green the path of php.ini and the folder ext according to installing php on your machine.
  7. Paste the file .dll of the Xdebug you downloaded from inside that folder ext. The php nicialization file (php.ini) will look for that file .dll inside this folder to enable the debogage function.
  8. So you need to write inside the php.ini the path (path) to that file .dll. And also pass on some information that the IDE will use for the debugging or debugging session. If you don’t, the IDE will throw an error message. Copy and paste the following lines at the bottom of your file php.ini then save:
  9. [XDebug]
  10. zend_extension="[AMP Path]\php\ext\php_xdebug.dll" THIS IS YOUR PATH TO . dll
  11. xdebug.remote_enable = 1
  12. xdebug.remote_handler = "dbgp"
  13. xdebug.remote_host = "127.0.0.1"
  14. xdebug.remote_port = 9000

    Once these steps are done, your IDE and PHP should already be set up for the deboning session. Restart the server and run the page containing the phpinfo(). You will notice that there was a change in the presentation of the page phpinfo. And the message showing that the Xdebug was successfully installed, see photo below: inserir a descrição da imagem aqui

Ready. From now on the debugger has been unsaved and configured on your machine. If you were using netbeans your config would stop here. To proceed with setting up Aptana follow this step by step.

And although it is not the scope of the question, put here a picture of a simple debugging session with Xdebug and Netbeans. Testing an element error with same id in DOM: inserir a descrição da imagem aqui

0

Opa does exist. If you want to debug a JS you can use the browser console itself by clicking the F12 key. On it you can browse to Sources( if it is google Chrome ) or in Scripts ( if it is firefox with the extension firebug installed )

If it’s an IDE there, it depends on which one you’re using. I work with JAVA and use eclipse, so I put breakpoint on the line I want to debug and run the application. When the line I set the breakpoint is executed the ide goes into action and shows you what goes behind the lines of code in the debug.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.