1.在homestead virtual box安裝和配置xdebug
先在終端運行vagrant up 和 vagrant ssh,ssh遠程到homestead,然后復制以下代碼到一個shell文件里面,並執行。
#!bash/bin cd ~ #download and uncompress wget https://xdebug.org/files/xdebug-2.4.0.tgz tar xvzf xdebug-2.4.0.tgz #compile and make install cd xdebug-2.4.0 phpize7.0 ./configure --enable-xdebug make sudo make install mkdir -p /usr/local/php/xdebug sudo cp ~/xdebug-2.4.0/modules/xdebug.so /usr/local/php/xdebug/xdebug.so cat>>xdebug.ini<<EOF zend_extension="/usr/local/php/xdebug/xdebug.so" xdebug.remote_enable = 1 xdebug.remote_connect_back = 1 xdebug.remote_port = 9000 xdebug.max_nesting_level = 500 EOF sudo cp xdebug.ini /etc/php/mods-available/xdebug.ini sudo ln -snf /etc/php/mods-available/xdebug.ini /etc/php/7.0/cli/conf.d/20-xdebug.ini sudo ln -snf /etc/php/mods-available/xdebug.ini /etc/php/7.0/fpm/conf.d/20-xdebug.ini service php7.0-fpm restart cd ~ sudo rm -R xdebug-2.4.0 sudo rm xdebug-2.4.0.tgz
2.根據瀏覽器安裝xdebug插件
Xdebug Helper for Chrome or JetBrains IDE Support
3.PHPStorm配置xdebug
3.1在導航上 Run->edit Configurations... 進入以下界面
根據上圖設置保存設置。
運行debug; 設置斷點,然后 運行 Run->debug,如下圖:
運行成功KO!
參考資料:
https://confluence.jetbrains.com/display/PhpStorm/Xdebug+Installation+Guide