有一個php項目源碼,如何搞清楚執行過程?畫出其流程圖

來源:互聯網
上載者:User
比如一個c項目,可以讓其運行起來,然後利用gdb調試,一步步執行,搞清楚其執行過程,那麼一個php項目,如何才能搞清楚執行過程呢,或者需要什麼專業的工具

回複內容:

比如一個c項目,可以讓其運行起來,然後利用gdb調試,一步步執行,搞清楚其執行過程,那麼一個php項目,如何才能搞清楚執行過程呢,或者需要什麼專業的工具

如果你想調試的話,可以使用zend studio 或者phpstrom 都是很好的工具

安裝 xdebug

然後自己配置:

; 輸出檔案路徑xdebug.trace_output_dir="/tmp"; 輸出檔案名xdebug.trace_output_name=trace.%H.%t; 記錄添加到檔案中方式:1 = 追加(如果存在該檔案). 0 (default) = 覆蓋(如果存在該檔案)xdebug.trace_options=0; trace 資料格式; 0   shows a human readable indented trace file; 1   writes a computer readable format which has two different records; 2   writes a trace formatted in (simple) HTMLxdebug.trace_format=0; 顯示資料; 0 = 不顯示.; 1 = 參數類型,值  (例如:array(9)).; 2 = 同上1,只是在CLI模式下略微有區別; 3 = 所有變數內容(受到 xdebug.var_display_max_children,xdebug.var_display_max_data 和xdebug.var_display_max_depth限制); 4 = 所有變數內容和變數名(例如:array(0 => 9)).xdebug.collect_params=0; 是否收集合函式傳回值xdebug.collect_return=0; 關閉自動追蹤,使用 XDEBUG_TRACE GET/POST 觸發追蹤, 或者通過設定cookie XDEBUG_TRACExdebug.auto_trace=0xdebug.trace_enable_trigger=1

這樣訪問你的應用,帶上特殊的參數就可以得到 trace 檔案了,比如:you.app/?XDEBUG_TRACE

然後安裝這個 vim 擴充https://github.com/xdebug/xdebug.org/blob/master/html/files/xt.vim

用 vim 開啟 trace 檔案,跟著執行流程往下看就行了。

xhprof

Zend Studio 就可以設斷點來跟蹤代碼

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.