Home  >  Article  >  php教程  >  笔记:MAC OS X下配置PHP开发、调试环境

笔记:MAC OS X下配置PHP开发、调试环境

WBOY
WBOYOriginal
2016-06-14 00:01:551017browse

 

操作系统:MAC OS X

工具:MAMP、PhpStorm、xdebug、chrome

 

1、下载MAMP

2、安装比较简单,安装完成后,应用程序中会增加如下4个应用

  

 

  MacGDBp是PHP调试器,使用的是xdebug

  若要使用此调试器,需要在php.ini中配置:

  

<span style="color: #000000;">[xdebug]
zend_extension</span>="/Applications/MAMP/bin/php/php5.5.10/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"<span style="color: #000000;">
xdebug</span>.remote_enable=1<span style="color: #000000;">
xdebug</span>.remote_host=<span style="color: #000000;">localhost
xdebug</span>.remote_port=9000<span style="color: #000000;">
xdebug</span>.remote_autostart=1

  zend_extension要根据自己使用的php具体版本和路径设置。

  xdebug.remote_port端口要与MacGDBp的Preferences中设置的端口一致。

  

  按上面两步配置完成后,打开MacGDBp,浏览器输入php站点地址,在执行第一行php代码时自动进入调试状态,即在第一行php代码自动加载断点。

  

  MAMP用于启动Apache和MySql服务,如下图所示:

  

 

  点击Start Servers会启动Apache 和 MySql服务,如下图所示:

  

 

    点击Open start page可以打开管理界面,用于查看phpInfo以及phpMyAdmin管理MySQL等工具。

    点击Preferences,可以配置Apache和MySql的端口,以及PHP版本等信息。

3、MySQLWorkbench和Sequel Pro都是MySql的管理工具,可根据实际情况使用。

 

4、下载并安装phpStorm,我安装的是7.1.3版本。

5、在php.ini中[xdebug]增加如下一行,xdebug.idekey的值可随意设置,我设置的是PHPSTORM。

xdebug.idekey="PHPSTORM"

6、打开PhpStorm的Preferences,找到PHP下的Debug,配置debug port为上面第2步php.ini中设置的端口9000,其他按默认设置即可。

  

7、浏览器配置,Chrome浏览器安装Xdebug helper

  安装好后,点击Chrome的[设置]菜单,点击[扩展程序]

  

  再点击Xdebug helper的选项

    

  设置IDE Key,在下拉列表中选择Other,输入PHPSTORM(也就是我们在前面步骤中的php.ini中设置的xdebug.idekey),输入完成后,点击保存图标即可。

  我们也可以直接在下拉列表中选择PhpStorm。

 

8、调试程序

  点击PhpStorm的菜单 Run -> Start Listen PHP Debug Connections 开启监听

  在PhpStom开发环境中,在php某行代码处设置断点

  Chrome浏览器中输入php网站的地址,在设置的断点处即可进行调试。

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP文件上传详解Next article:mac系统使用内置的 PHP