
一、XAMPP
XAMPP是最流行的PHP开发环境,它包含Apache、MariaDB、PHP、Perl。
官网下载地址
下载完成后直接安装,

安装成功后,选择Manage Servers,全部启动。

如果你的MySQL启动失败,尝试一下在终端输入下面一行代码:
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
然后,在浏览器里输入localhost,

下面添加Xdebug调试器,最新版本的XAMPP默认自带的xdebug.so模块:

通过vim打开Applications/XAMPP/etc/php.ini 配置文件,在最后加入下面代码:
[xdebug] zend_extension="/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so" xdebug.remote_enable=on xdebug.remote_handler=dbgp xdebug.remote_host=localhost xdebug.remote_port=9000 xdebug.profiler_enable=1 xdebug.remote_log="/Applications/XAMPP/xamppfiles/logs/xdebug.log" xdebug.idekey="PHPSTORM"
设置完之后,重启Apache
sudo /Applications/XAMPP/xamppfiles/bin/apachectl restart
再次在浏览器输入localhost

xdebug就安装好了。
二、PhpStorm
PhpStorm是一个轻量级、便捷的PHP IDE,它的优点很多,这里就不在一一赘述,先去官网下载最新版本。官网下载地址
下载后,也是直接安装,路径设置成默认即可。
这里需要注册

点击OK,PhpStorm就安装好了。
主题、字体

PHP是解释型动态语言,必须设置Interpreters

Xdebug和服务器配置


上面两者的port要保持一致。另外,下面的Debug Port要与前面php.ini 里的 xdebug.remote_port的值保持一致。

到这里,环境搭建基本完成了,现在让我们进行调试

点击run

good ! 运行正常,现在开始我们的PHP之旅吧。
网友评论