creamidea / creamidea.github.com

冰糖火箭筒&&蜂蜜甜甜圈
https://creamidea.github.io/
4 stars 4 forks source link

Debug PHP #26

Open creamidea opened 7 years ago

creamidea commented 7 years ago

Using PHPStorm and Built-in Server

  1. install xdebug
  2. Config PHPStorm:
    • Add Built-in Server: Preferences > Languages & Framework > +
    • Configurations: Add PHP Built-in Server
  3. Click Start (and telephone icon?)
creamidea commented 7 years ago

搭建 PHP 开发环境

PHP

安装 PHP

brew install --without-apache --with-fpm php71

安装到这里 /usr/local/opt/php71(实际是在 /usr/local/Cellar/php71/$VERSION) 配置文件路径:/usr/local/etc/php/$VERSION

启动:php-fpm

安装 xdebug

brew install php71-xdebug 在 php.ini 最后或者在 conf.d/ext-xdebug.ini 中增加

[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1

;; default
;; xdebug.remote_host="localhost"
;; xdebug.remote_handler=dbgp
;; xdebug.remote_port=9009

nginx

brew install nginx

安装到 /usr/local/opt/nginx (实际在/usr/local/Cellar/nginx/1.12.1) 配置文件路径:/usr/local/etc/nginx

核心配置

location ~ \.php$ {
    fastcgi_pass   unix:/var/tmp/php-fpm.sock;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME $document_root/$fastcgi_script_name;
    include        fastcgi_params;
}

启动:nginx 停止:nginx -s stop

VSCode

下载安装插件 PHP Debug。 之后你就可以欢快的打断点尽心调试啦。

尾声

祝玩的开心~