1、安装Xdebug
wgethttp://xdebug.org/files/xdebug-2.2.3.tgz
tarxzvfxdebug-2.2.3.tgz
cdxdebug-2.2.3
phpize
./configure
make
sudomakeinstall
2、启用xdebug:
在php.ini中加入如下一行(我的是mac) :
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
参考http://netbeans.org/kb/docs/php/debugging_zh_CN.html
3、开启php.ini 中的调试功能
;xdebug.auto_trace
;Type:boolean,Defaultvalue:0
;Whenthissettingissettoon,thetracingoffunctioncallswillbeenabledjustbeforethe
;scriptisrun.Thismakesitpossibletotracecodeintheauto_prepend_file.
xdebug.auto_trace=0
;xdebug.collect_includes
;Type:boolean,Defaultvalue:1
;Thissetting,defaultingtoOn,controlswhetherXdebugshouldwritethefilenameusedininclude
;(),include_once(),require()orrequire_once()tothetracefiles.
xdebug.collect_includes=1
;xdebug.collect_params
;Type:integer,Defaultvalue:0
;
;Thissetting,defaultingto0,controlswhetherXdebugshouldcollecttheparameterspassedto
;functionswhenafunctioncallisrecordedineitherthefunctiontraceorthestacktrace.
xdebug.collect_params=0
;xdebug.collect_return
;Type:boolean,Defaultvalue:0
;Thissetting,defaultingtoOff,controlswhetherXdebugshouldwritethereturnvalueoffunction
;callstothetracefiles.
xdebug.collect_return=0
;xdebug.collect_vars
;Type:boolean,Defaultvalue:Off
;ThissettingtellsXdebugtogatherinformationaboutwhichvariablesareusedinacertainscope.
;ThisanalysiscanbequiteslowasXdebughastoreverseengineerPHP'sopcodearrays.Thissetting
;willnotrecordwhichvaluesthedifferentvariableshave,forthatusexdebug.collect_params.This
;settingneedstobeenabledonlyifyouwishtousexdebug_get_declared_vars().
xdebug.collect_vars="Off"
;xdebug.default_enable
;Type:boolean,Defaultvalue:On
;IfthissettingisOnthenstacktraceswillbeshownbydefaultonanerrorevent.Youcandisable
;showingstacktracesfromyourcodewithxdebug_disable().Asthisisoneofthebasicfunctionsof
;Xdebug,itisadvisabletoleavethissettingsetto'On'.
xdebug.default_enable="On"
;xdebug.dump.*
;Type:string,Defaultvalue:Empty
;*=COOKIE,FILES,GET,POST,REQUEST,SERVER,SESSION.Thesesevensettingscontrolwhichdata
;fromthesuperglobalsisshownwhenanerrorsituationoccurs.Eachphp.inisettingcanconsistof
;acommaseperatedlistofvariablesfromthissuperglobaltodump,butmakesureyoudonotadd
;spacesinthissetting.InordertodumptheREMOTE_ADDRandtheREQUEST_METHODwhenanerror
;occurs,addthissetting:
;
;xdebug.dump.SERVER=REMOTE_ADDR,REQUEST_METHOD
;xdebug.dump.SERVER=REMOTE_ADDR,REQUEST_METHOD
;xdebug.dump.COOKIE=""
;xdebug.dump.FILES=""
;xdebug.dump.GET=""
;xdebug.dump.POST=""
;xdebug.dump.REQUEST=""
;xdebug.dump.SERVER=""
;xdebug.dump.SESSION=""
;xdebug.dump_globals
;Type:boolean,Defaultvalue:1
;Controlswhetherthevaluesofthesuperglobalsasdefinedbythexdebug.dump.*settingswhouldbe
;shownornot.
xdebug.dump_globals=1
;xdebug.dump_once
;Type:boolean,Defaultvalue:1
;Controlswhetherthevaluesofthesuperglobalsshouldbedumpedonallerrorsituations(setto
;Off)oronlyonthefirst(settoOn).
xdebug.dump_once=1
;xdebug.dump_undefined
;Type:boolean,Defaultvalue:0
;IfyouwanttodumpundefinedvaluesfromthesuperglobalsyoushouldsetthissettingtoOn,
;otherwiseleaveitsettoOff.
xdebug.dump_undefined=0
;xdebug.extended_info
;Type:integer,Defaultvalue:1
;ControlswhetherXdebugshouldenforce'extended_info'modeforthePHPparser;thisallowsXdebug
;todofile/linebreakpointswiththeremotedebugger.Whentracingorprofilingscriptsyou
;generallywanttoturnoffthisoptionasPHP'sgeneratedoparrayswillincreasewithaboutathird
;ofthesizeslowingdownyourscripts.Thissettingcannotbesetinyourscriptswithini_set(),
;butonlyinphp.ini.
xdebug.extended_info=1
;xdebug.file_link_format
;Type:string,Defaultvalue:*emptystring*,IntroducedinXdebug2.1
;
;Thissettingdeterminestheformatofthelinksthataremadeinthedisplayofstacktraceswhere
;filenamesareused.ThisallowsIDEstosetupalink-protocolthatmakesitpossibletogo
;directlytoalineandfilebyclickingonthefilenamesthatXdebugshowsinstacktraces.
;xdebug.file_link_format=""
;xdebug.idekey
;Type:string,Defaultvalue:*complex*
;ControlswhichIDEKeyXdebugshouldpassontotheDBGpdebuggerhandler.Thedefaultisbasedon
;environmentsettings.FirsttheenvironmentsettingDBGP_IDEKEYisconsulted,thenUSERandaslast
;USERNAME.Thedefaultissettothefirstenvironmentvariablethatisfound.Ifnonecouldbe
;foundthesettinghasasdefault''.
;xdebug.idekey=""
;xdebug.manual_url
;Type:string,Defaultvalue:http://www.php.net
;Thisisthebaseurlforthelinksfromthefunctiontracesanderrormessagetothemanualpages
;ofthefunctionfromthemessage.Itisadvisabletosetthissettingtousetheclosestmirror.
;xdebug.manual_url="http://www.php.net"
;xdebug.max_nesting_level
;Type:integer,Defaultvalue:100
;Controlstheprotectionmechanismforinfiniterecursionprotection.Thevalueofthissettingis
;themaximumlevelofnestedfunctionsthatareallowedbeforethescriptwillbeaborted.
;xdebug.max_nesting_level=100
;xdebug.overload_var_dump
;Type:boolean,Defaultvalue:1,IntroducedinXdebug2.1
;BydefaultXdebugoverloadsvar_dump()withitsownimprovedversionfordisplayingvariableswhen
;thehtml_errorsphp.inisettingissetto1.Incaseyoudonotwantthat,youcansetthissetting
;to0,butcheckfirstifit'snotsmartertoturnoffhtml_errors.
;xdebug.overload_var_dump=1
;xdebug.profiler_append
;Type:integer,Defaultvalue:0
;Whenthissettingissetto1,profilerfileswillnotbeoverwrittenwhenanewrequestwouldmap
;tothesamefile(depndingonthexdebug.profiler_output_namesetting.Insteadthefilewillbe
;appendedtowiththenewprofile.
xdebug.profiler_append=0
;xdebug.profiler_enable
;Type:integer,Defaultvalue:0
;EnablesXdebug'sprofilerwhichcreatesfilesintheprofileoutputdirectory.Thosefilescanbe
;readbyKCacheGrindtovisualizeyourdata.Thissettingcannotbesetinyourscriptwithini_set
;().
xdebug.profiler_enable=0
;xdebug.profiler_enable_trigger
;Type:integer,Defaultvalue:0
;Whenthissettingissetto1,youcantriggerthegenerationofprofilerfilesbyusingthe
;XDEBUG_PROFILEGET/POSTparameter.Thiswillthenwritetheprofilerdatatodefineddirectory.
xdebug.profiler_enable_trigger=0
;xdebug.profiler_output_dir
;Type:string,Defaultvalue:/tmp
;Thedirectorywheretheprofileroutputwillbewrittento,makesurethattheuserwhothePHP
;willberunningashaswritepermissionstothatdirectory.Thissettingcannotbesetinyour
;scriptwithini_set().
xdebug.profiler_output_dir="D:/ProgramFiles/XAMPP/xampp/tmp"
;xdebug.profiler_output_name
;Type:string,Defaultvalue:cachegrind.out.%p
;
;Thissettingdeterminesthenameofthefilethatisusedtodumptracesinto.Thesetting
;specifiestheformatwithformatspecifiers,verysimilartosprintf()andstrftime().Thereare
;severalformatspecifiersthatcanbeusedtoformatthefilename.
;
;Seethexdebug.trace_output_namedocumentationforthesupportedspecifiers.
xdebug.profiler_output_name="xdebug_profile.%p"
;xdebug.remote_autostart
;Type:boolean,Defaultvalue:0
;NormallyyouneedtouseaspecificHTTPGET/POSTvariabletostartremotedebugging(seeRemote
;Debugging).Whenthissettingissetto'On'Xdebugwillalwaysattempttostartaremotedebugging
;sessionandtrytoconnecttoaclient,eveniftheGET/POST/COOKIEvariablewasnotpresent.
xdebug.remote_autostart=0
;xdebug.remote_enable
;Type:boolean,Defaultvalue:0
;ThisswitchcontrolswhetherXdebugshouldtrytocontactadebugclientwhichislisteningonthe
;hostandportassetwiththesettingsxdebug.remote_hostandxdebug.remote_port.Ifaconnection
;cannotbeestablishedthescriptwilljustcontinueasifthissettingwasOff.
xdebug.remote_enable=1
;xdebug.remote_handler
;Type:string,Defaultvalue:dbgp
;Canbeeither'php3'whichselectstheoldPHP3styledebuggeroutput,'gdb'whichenablestheGDB
;likedebuggerinterfaceor'dbgp'-thebrandnewdebuggerprotocol.TheDBGpprotocolismore
;widelysupportedbyclients.SeemoreinformationintheintroductionforRemoteDebugging.
xdebug.remote_handler="dbgp"
;xdebug.remote_host
;Type:string,Defaultvalue:localhost
;Selectsthehostwherethedebugclientisrunning,youcaneitheruseahostnameoranIP
;address.
xdebug.remote_host="localhost"
;xdebug.remote_log
;Type:string,Defaultvalue:none
;Ifsettoavalue,itisusedasfilenametoafiletowhichallremotedebuggercommunicationsare
;logged.Thefileisalwaysopenedinappend-mode,andwillthereforenotbeoverwrittenbydefault.
;Thereisnoconcurrencyprotectionavailable.
;xdebug.remote_log="none"
;xdebug.remote_mode
;Type:string,Defaultvalue:req
;
;Selectswhenadebugconnectionisinitiated.Thissettingcanhavetwodifferentvalues:
;
;req
;Xdebugwilltrytoconnecttothedebugclientassoonasthescriptstarts.
;jit
;Xdebugwillonlytrytoconnecttothedebugclientassoonasanerrorconditionoccurs.
;xdebug.remote_mode="req"
;xdebug.remote_port
;Type:integer,Defaultvalue:9000
;TheporttowhichXdebugtriestoconnectontheremotehost.Port9000isthedefaultforboththe
;clientandthebundleddebugclient.Asmanyclientsusethisportnumber,itisbesttoleavethis
;settingunchanged.
xdebug.remote_port=9000
;xdebug.show_exception_trace
;Type:integer,Defaultvalue:0
;Whenthissettingissetto1,Xdebugwillshowastacktracewheneveranexceptionisraised-
;evenifthisexceptionisactuallycaught.
;xdebug.show_exception_trace=0
;xdebug.show_local_vars
;Type:integer,Defaultvalue:0
;Whenthissettingissettosomething!=0Xdebug'sgeneratedstackdumpsinerrorsituationswill
;alsoshowallvariablesinthetop-mostscope.Bewarethatthismightgeneratealotof
;information,andisthereforeturnedoffbydefault.
;xdebug.show_local_vars=0
;xdebug.show_mem_delta
;Type:integer,Defaultvalue:0
;Whenthissettingissettosomething!=0Xdebug'shuman-readablegeneratedtracefileswillshow
;thedifferenceinmemoryusagebetweenfunctioncalls.IfXdebugisconfiguredtogenerate
;computer-readabletracefilesthentheywillalwaysshowthisinformation.
;xdebug.show_mem_delta=0
;xdebug.trace_format
;Type:integer,Defaultvalue:0
;Theformatofthetracefile.
;
;SeetheintroductionofFunctionTracesforafewexamples.
;xdebug.trace_format=0
;xdebug.trace_options
;Type:integer,Defaultvalue:0
;Whensetto'1'thetracefileswillbeappendedto,insteadofbeingoverwritteninsubsequent
;requests.
;xdebug.trace_options=0
;xdebug.trace_output_dir
;Type:string,Defaultvalue:/tmp
;Thedirectorywherethetracingfileswillbewrittento,makesurethattheuserwhothePHPwill
;berunningashaswritepermissionstothatdirectory.
;xdebug.trace_output_name
xdebug.trace_output_dir="D:/ProgramFiles/XAMPP/xampp/tmp"
;Type:string,Defaultvalue:trace.%c
;
;Thissettingdeterminesthenameofthefilethatisusedtodumptracesinto.Thesetting
;specifiestheformatwithformatspecifiers,verysimilartosprintf()andstrftime().Thereare
;severalformatspecifiersthatcanbeusedtoformatthefilename.The'.xt'extensionisalways
;addedautomatically.
;xdebug.trace_output_name="trace.%c"
;xdebug.var_display_max_children
;Type:integer,Defaultvalue:128
;Controlstheamountofarraychildrenandobject'spropertiesareshownwhenvariablesare
;displayedwitheitherxdebug_var_dump(),xdebug.show_local_varsorthroughFunctionTraces.This
;settingdoesnothaveanyinfluenceonthenumberofchildrenthatissendtotheclientthrough
;theRemoteDebuggingfeature.
;xdebug.var_display_max_children=128
;xdebug.var_display_max_data
;Type:integer,Defaultvalue:512
;Controlsthemaximumstringlengththatisshownwhenvariablesaredisplayedwitheither
;xdebug_var_dump(),xdebug.show_local_varsorthroughFunctionTraces.Thissettingdoesnothave
;anyinfluenceontheamountofdatathatissendtotheclientthroughtheRemoteDebugging
;feature.
;xdebug.var_display_max_data=512
;xdebug.var_display_max_depth
;Type:integer,Defaultvalue:3
;Controlshowmanynestedlevelsofarrayelementsandobjectpropertiesarewhenvariablesare
;displayedwitheitherxdebug_var_dump(),xdebug.show_local_varsorthroughFunctionTraces.This
;settingdoesnothaveanyinfluenceonthedepthofchildrenthatissendtotheclientthroughthe
;RemoteDebuggingfeature.
;xdebug.var_display_max_depth=3
我的是使用的是phpStorm
我的简单的配置为:
xdebug.auto_trace=on
xdebug.idekey="PHPSTORM"
xdebug.remote_host=127.0.0.1
xdebug.remote_enable=on
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.auto_trace=1
xdebug.collect_includes=1
xdebug.collect_params=1
xdebug.collect_return=1
xdebug.default_enable=1
xdebug.collect_assignments=1
xdebug.collect_vars=1
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
xdebug.show_local_vars=1
xdebug.show_exception_trace=0
注意:xdebug输出没样式了
解决办法就是
将html_errors改为On