1. 程式人生 > >mac環境下支持PHP調試工具xdebug,不需要建項目server

mac環境下支持PHP調試工具xdebug,不需要建項目server

qjm nic seq https nec updating bin mitm jcu

brew install php56 --with-imap --with-tidy --with-debug --with-mysql --with-fpm do not use --with-debug brew install php56 --with-imap --with-tidy --with-mysql --with-fpm brew search php56-xdebug https://xdebug.org/wizard.php

xingchongs-MacBook-Pro-3:~ xingchong$

xingchongs-MacBook-Pro-3:~ xingchong$

xingchongs-MacBook-Pro-3:~ xingchong$ brew search php56-xdebug

==> Searching local taps...

josegonzalez/php/php56-xdebug

==> Searching taps on GitHub...

homebrew/php/php56-xdebug

==> Searching blacklisted, migrated and deleted formulae...

xingchongs-MacBook-Pro-3:~ xingchong$ brew install josegonzalez/php/php56-xdebug

Updating Homebrew...

==> Installing php56-xdebug from josegonzalez/php

==> Downloading https://homebrew.bintray.com/bottles-php/php56-xdebug-2.5.5.sierra.bottle.tar.gz

######################################################################## 100.0%

==> Pouring php56-xdebug-2.5.5.sierra.bottle.tar.gz

==> Caveats

To finish installing xdebug for PHP 5.6:

* /usr/local/etc/php/5.6/conf.d/ext-xdebug.ini was created,

do not forget to remove it upon extension removal.

* Validate installation via one of the following methods:

*

* Using PHP from a webserver:

* - Restart your webserver.

* - Write a PHP page that calls "phpinfo();"

* - Load it in a browser and look for the info on the xdebug module.

* - If you see it, you have been successful!

*

* Using PHP from the command line:

* - Run `php -i "(command-line ‘phpinfo()‘)"`

* - Look for the info on the xdebug module.

* - If you see it, you have been successful!

==> Summary

?? /usr/local/Cellar/php56-xdebug/2.5.5: 4 files, 196KB

xingchongs-MacBook-Pro-3:~ xingchong$

xingchongs-MacBook-Pro-3:~ xingchong$

xingchongs-MacBook-Pro-3:~ xingchong$

先讓php支持xdebug 方式一: https://xdebug.org/download.php 下載相應的xdebug 可以到http://xdebug.org/wizard.php 把phpinfo的所有信息粘貼上去,會給出相應的版本 解壓 tar -zxvf xdebug cd xdebug目錄下 執行 phpize(我的目錄是/usr/local/bin/phpize,用sudo執行) 報錯出現Cannot find autoconf. Please check your autoconf 查原因是需要裝autoconf Brew install autoconf ok 後 ./configure --enable-xdebug make && make install 方式二: 用brew search php 找到xdebug擴展 brew install homebrew/php/xdebug-osx 安裝完成,出現如下提示: Installing shared extensions: /usr/local/Cellar/php56/5.6.32_8/lib/php/extensions/no-debug-non-zts-20131226/ +----------------------------------------------------------------------+ | | | INSTALLATION INSTRUCTIONS | | ========================= | | | | See http://xdebug.org/install.php#configure-php for instructions | | on how to enable Xdebug for PHP. | | | | Documentation is available online as well: | | - A list of all settings: http://xdebug.org/docs-settings.php | | - A list of all functions: http://xdebug.org/docs-functions.php | | - Profiling instructions: http://xdebug.org/docs-profiling2.php | | - Remote debugging: http://xdebug.org/docs-debugger.php | | | | | | NOTE: Please disregard the message | | You should add "extension=xdebug.so" to php.ini | | that is emitted by the PECL installer. This does not work for | | Xdebug. | | | +----------------------------------------------------------------------+ 配置php.ini,在phpinfo裏看清楚自己的配置文件 [Xdebug] ;extension=php_xdebug.dll zend_extension = "/usr/local/Cellar/php56/5.6.32_8/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so" xdebug.auto_trace=1 xdebug.collect_params=1 xdebug.collect_return=1 xdebug.trace_output_dir="/usr/local/var/xdebug/trace" xdebug.profiler_enable=1 xdebug.profiler_output_dir="/usr/local/var/xdebug/profiler" xdebug.remote_autostart=1 #自動 xdebug.remote_enable=true xdebug.remote_host=localhost xdebug.remote_port=9050 #我用的php-fpm方式啟動的PHP,9000端口被它占了,所以換端口 xdebug.remote_handler = “dbgp” #不寫,默認也是dbgp xdebug.idekey = PHPSTORM #可不寫,默認會是環境變量 重啟php 以上是配置php支持xdebug,用php -v 或者phpinfo 看到xdebug開了就行了。 ---------------------------------------------- 設置phpstorm監聽xdebug 折騰了近2天,真是 起初應該是PHP和xdebug不匹配,直接下了個2.5.5的,檢測過沒註意到說要2.5.4,然後入坑裏出不來,以上的配置主要是extension的路徑要寫對,autostart 配置為1, 以上這些配置在xdebug官網裏都有說明,不過關鍵的xdebug的原理看https://xdebug.org/docs/remote dbgp的說明:https://xdebug.org/docs-dbgp.php#standard-dbgp-port ------ 說phpstorm裏的配置,在 技術分享圖片 dbgp的默認端口應該都是80吧,ide key 寫配置裏的值就好,端口應該都是80,開始時默認是9001沒改 ----------------------------- 另外補充,點蟲子邊上的edit config裏的幾個配置介紹 phpstorm的官網裏https://confluence.jetbrains.com/display/PhpStorm/Debugging+PHP+Web+Applications+with+Run+Debug+Configurations對 技術分享圖片都有說明

mac環境下支持PHP調試工具xdebug,不需要建項目server