zoukankan      html  css  js  c++  java
  • phpstorm mac xdebug配置


    #在mac上用phpstorm里debug调试php
    ## 背景
    最近为了完成某个需求,在看`smarty`源码,当我尝试直接看,痛苦的快吐血,工欲善其事必先利器,虽然之前一直使用phpstorm调试nodejs,但是还没有用phpstorm来debug过php。

    ## 建议
    先看看这个:PhpStorm 8.0.2 Help :: Configuring Xdebug
    ## 安装xdebug
    1. 打开:Xdebug: Downloads 点击source来下载源码包
    2. 然后安装
    ```bash
    #解压tar包
    tar -xzf xdebug-2.2.5.tgz
    #进入根目录
    cd xdebug-2.2.5
    #执行phpize
    phpize
    #编译安装xdebug
    ./configure --enable-xdebug
    make
    make install
    ```
    ## 配置到php
    1. 打开php.ini文件
    ```bash
    cd /private/etc/
    #默认没有php.ini,需要拷贝一下
    sudo cp php.ini.default php.ini
    sudo vi php.ini
    ```
    2. 在下面加入
    ```bash
    [Xdebug]
    zend_extension="/usr/local/php_user/xdebug.so"
    xdebug.remote_enable = on
    ;xdebug.remote_handler=dbgp
    xdebug.remote_host="127.0.0.1"
    xdebug.remote_port=9000
    xdebug.profiler_enable = 1
    xdebug.profiler_enable_trigger = off
    xdebug.profiler_output_name = cachegrind.out.%t.%p
    xdebug.remote_autostart = on
    ```
    3. 重启`apache`
    ```bash
    sudo apachectl restart
    ```
    4. 查看phpinfo()信息里面搜索一下`debug`如果有,你成功了。



    ## 配置phpstorm
    1. 打开phpstorm,进入顶部导航`phpstrom->perferences..`
    2. 点击`php`项,点击`interpreter`后面的`...`按钮
    3. 点击`php home`后面的刷新(`...`后面)按钮
    4. 这时候你将看到`Debugger: Not installed`变成`Xdebug 2.3.2`(版本号可能不同)
    6. 进入`php`栏目下的`Server`,点击`+`新建一个server:host填写你本地的host(如127.0.0.1),点击`apply`保存,并退出`perferences`对话框。
    7. 点击顶部导航`run`->点击`+`->选择`PHP Web Application`->选择上一步新建的`server`,`start URL`填入,你要debug的php文件地址,下面会生成一个地址,这个地址在浏览器应该能正常浏览测试的;点击`apply`进行保存。

    ## 开始愉快的使用
    1. 在你要debug的文件行数字右侧一列,点击一下就会有一个断点。
    2. 点击顶部导航`run`->debug,选择你刚刚新建的`debug`名称,这时候会弹出浏览器加载这个php文件了。
     
    参考网站:https://segmentfault.com/a/1190000005878593
    http://blog.csdn.net/zhyh1986/article/details/45172685
  • 相关阅读:
    List of the best open source software applications
    Owin对Asp.net Web的扩展
    NSwag给api加上说明
    'workspace' in VS Code
    unable to find valid certification path to requested target
    JMeter的下载以及安装使用
    exception disappear when forgot to await an async method
    Filter execute order in asp.net web api
    记录web api的request以及response(即写log)
    asp.net web api的源码
  • 原文地址:https://www.cnblogs.com/Aaronqcd/p/5965812.html
Copyright © 2011-2022 走看看