What is the procedure for debugging a "stack execution", Javascript or Php through the browser or IDE Aptana?

6

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

Is there any way, where through the browser or an IDE, where we can follow 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.

    
asked by anonymous 04.06.2016 / 19:04

2 answers

3

For javascript use the Chrome debugger. Just press F12 and it will appear. Go to the console option and dump it.

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

To run a debugger in an IDE you need:

  • Configure the debugger or debugger in the php initialization file, php.ini .
  • Configure the IDE to accept the already installed debugger. NOTE: If you use netbeans, this step is not required because it recognizes the configuration within php.ini automatically.
  • Regardless of the IDE used you will have to configure xdebug in php.ini and that is the hardest part. The second part of IDE Aptana I will pass the link with the step by step.

  • Create a project with any name and then a page containing phpinfo(); only;
  • Open the browser that displays phpinfo information and copy everything (% with% and then% with%)
  • Go to that xdebug link and paste your content in the appropriate space and hit the button Analyze my phpinfo output . See photo below:
  • Thistoolwillfindthedllextataforyourversionofphp.Seethephotobelow:
  • Clickonthedllfileanddownloadit.
  • SearchforthefolderwherethePHPextensions(ext)arelocated.InsomeinstallationsitisdirectlyinsidethePHPdirectory(php>ext)inothersitisinsidethebinfolder(php>bin>ext).Notethatthetoolshowedyouthepathtophp.iniandtheextfolderaspertheinstallationofphponyourmachine.
  • Pastethexdebug.dllfilethatyoudownloadedintothisextfolder.Thephp(php.ini)bootarchivewilllookforthis.dllfilewithinthisfoldertoenablethedebuggingfunction.
  • So,youneedtowritephp.inithepathtothis.dllfile.AndinadditionpasssomeinformationthattheIDEwilluseforthesessionofdebuggingordebugging.Ifyoudonotdothis,theIDEwillthrowanerrormessage.Copyandpastethefollowinglinesattheendofyourphp.inifilethensave:
  • crtl+a
  • %WITH_%THATISYOURPATHUNTILTHE.dll
  • crtl+c
  • [XDebug]
  • zend_extension="[AMP Path]\php\ext\php_xdebug.dll"
  • xdebug.remote_enable = 1

    Following these steps, your IDE and your PHP should already be configured for the debugging session. Reboot the server and re-run the page containing xdebug.remote_handler = "dbgp" . You will notice that there was a change in the presentation of the phpinfo page. And the message showing that xdebug was successfully installed, see photo below:

  • It'sready.Fromnowonthedebuggerhasalreadybeeninstalledandconfiguredonyourmachine.Ifyouwereusingnetbeansyourconfigwouldstophere.TocontinuewiththeAptanaconfigurationfollowthis step by step .

    And although it is not the scope of the question, post here a photo of a simple debugging session with xDebug and NetBeans. Testing an element error with same id in DOM:

        
    07.06.2016 / 08:54
    0

    Oops, there is. If you are debugging a JS you can use the browser console itself by clicking the f12 key. In it you can navigate to Sources (if it's google chrome) or in scripts (if it is firefox with the extension firebug installed)

    If it is an IDE then it will depend on what you are using. I work with JAVA and use eclipse, so I put the breakpoint on the line that I want to debug and execute the application. When I run the line I put the breakpoint to ide goes into action and shows you what happens behind the lines of code in the debug.

        
    07.06.2016 / 02:23