[英]Debugging php-cli scripts with xdebug and netbeans?
我已經設法從IDE本身啟動php-cli腳本調試會話,但是我需要從shell /命令行啟動調試會話。 這些是相當復雜的維護PHP腳本,需要許多輸入參數,因此從Netbeans中輸入參數有點麻煩。
我之前在Zend Studio中已經做到了: https : //zend18.zendesk.com/hc/en-us/articles/203838096-Debugging-PHP-CLI-Scripts ,但是現在我需要使其與Netbeans一起使用。
提前致謝。
我通過以下方法在Ubuntu / Netbeans上進行此工作:
export XDEBUG_CONFIG="idekey=netbeans-xdebug"
然后,這只是在netbeans中啟動調試並在命令行執行php myscript.php
情況。
注意:如果要使用netbeans進行遠程調試,則需要在從命令行運行的文件上使用Debug File,而不是正常的Debug。
將xdebug.remote_autostart=On
添加到您的php.ini文件中,或將-dxdebug.remote_autostart=On
添加為PHP二進制調用的參數( php -d... script.php
)。
我將全部放在一起,以下是對我有用的。
file:
/etc/php5/cli/php.ini
zend_extension="/usr/lib/php5/20121212/xdebug.so" -> xdebug bin path
xdebug.remote_enable=on
xdebug.remote_host=127.0.0.1
xdebug.remote_handler="dbgp"
xdebug.remote_mode="req"
xdebug.remote_port=9000 -> same port configured in netbeans debugging tab
xdebug.idekey="netbeans-xdebug" -> same ide configured in netbeans debuggin tab
xdebug.remote_autostart=1
然后,沒有任何其他參數
php腳本.php
我有同樣的問題,我的解決方案是這樣的:
我有同樣的問題,我的解決方案是這樣的:
在Netbeans>項目窗口>右鍵單擊php項目>屬性>運行配置。 創建一個新配置。
填寫正確的值:
如果您不想為IDE配置xDebug(我討厭配置),則可以使用Dephpugger項目。
https://github.com/tacnoman/dephpugger
您可以在終端中運行調試器,例如python的ipdb和Ruby的byebug。
確保還設置了DBGP_IDEKEY值,因為通常它不是idekey 。 例如在Linux上:
export DBGP_IDEKEY="netbeans-xdebug"
export XDEBUG_CONFIG="netbeans-xdebug=netbeans-xdebug"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.