Ubuntu+phpstorm+firefox+xdebug的配置

本機使用Ubuntu14.04,phpstorm 2017.1, php5.5.9
須要使用的軟件和依賴: php5, php5-dev, php5-cgi, php5-xdebug
apache, php請記得安裝

1.安裝apache

安裝完成後,配置ServerName
位置在/etc/apache2/sites-available/000-default.conf
找到後,用Vim更改:php

ServerName 127.0.0.1

增長ServerName

2.安裝php5

安裝完成,獲取php信息:html

php-i > 「info.txt」

3.安裝phpstorm

將info.txt裏面的信息複製到https://xdebug.org/wizard.php
按照網站給與的提示一步步安裝web

4.安裝xdebug

在firefox,下面簡稱ff,菜單-附加組件-獲取附加組件-搜索'xdebug',而後安裝apache

xdebug設置

5.配置php5

在apache根目錄(默認爲/var/www/html/)寫一個php文件info.php,代碼爲瀏覽器

<?php
    phpinfo();

訪問localhost/info.phpapp

phpinfo

看到配置文件所在位置爲:phpstorm

/etc/php5/apache2/php.ini

在php.ini文件末尾增長如下配置:ide

[Xdebug]
zend_extension = /usr/lib/php5/20121212/xdebug.so
xdebug.idekey = "PHPSTORM"
xdebug.auto_trace = on
xdebug.default_enable = on
xdebug.auto_profile = on
xdebug.collect_params = on
xdebug.collect_return = on
xdebug.profiler_enable = on
xdebug.remote_enable = 1
xdebug.remote_host = localhost
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.remote_connect_back = 1
xdebug.trace_output_dir = "/usr/local/php/xdebug/"
xdebug.profiler_output_dir = "/usr/local/php/xdebug/"

重啓apache:網站

sudo service apache2 restart

打開info.php,看到有xdebug的配置信息:spa

xdebug配置信息

6.配置phpstorm

File– Settings - Languages & Frameworks

  • PHP

languages-php

  • PHP– Debug – Xdebug:

Debugport: 9000 PHP– Debug – Xdebug

  • DBGPPROXY:

lang-php-debug-dbgp

  • Servers:

lang-php-debug-servers

  • Run-Debug Configurations:

debug-config-http_requestdebug-config-web_application

7.配置完成,開始使用

  • 打開phpStorm的小電話圖標

little-phone

  • 打開ff的小瓢蟲圖標

little-bug

  • 在php源文件某行設置斷點

set-break-points

  • 在瀏覽器訪問該php文件

visit-hi.php

  • 就有斷點效果了

break_point_shows

相關文章
相關標籤/搜索