dqcuq4138 2016-08-09 23:45
浏览 56


My PHP dev environment is running on a VirtualBox VM and is provisioned via vagrant. How can I use php-debug in Atom on my host machine to debug PHP scripts running on one of my VMs?

  • 写回答

1条回答 默认 最新

  • duanhangjian8149 2016-08-09 23:45

    Configure xdebug:

    Open your php.ini file on your VM and look for the xdebug settings and make sure that you have the following values:


    Note: you may have multiple php.ini files, e.g. one for cli, fpm, etc… If you do, you’ll need to make sure that you have the xdebug settings above for all environments where you want to use the debugger, e.g. I had to modify /etc/php5/cli/php.ini to use the debugger on the command line and /etc/php5/fpm/php.ini to use the debugger while running PHP scripts with apache.

    Restart your web server or any other PHP related services, e.g.

    $ sudo service apache2 restart
    $ sudo service php5-fpm restart

    Install the php-debug package in Atom:

    Go to Atom -> Preferences -> Install, search for php-debug and install the package

    Configure php-debug in Atom:

    • Atom -> Preferences -> Packages, search for php-debug and click Settings

    • Set the PathMaps in the form remote;local. The PathMaps translate the guest/remote path to the local/host path. Let’s assume that you are debugging foo.php and that it can be found on your VM at /var/www/mysite/foo.php and on your host box at /Users/someuser/Documents/vagrant-mysite/foo.php. Your PathMaps config would then be /var/www/mysite;/Users/someuser/Documents/vagrant-mysite.

    • Server Port: 9999

    Start debugging:

    • Open your target source file in Atom, e.g. /Users/someuser/Documents/vagrant-mysite/foo.php

    • In the bottom left corner of your Atom screen, click the “PHP Debug” button

    • Set a breakpoint by clicking immediately left of your target line of code

    • Visit foo in the browser, e.g. http://example.com/foo.php and this should cause the code to pause in Atom and you should be able to continue debugging

    • If you configured the php.ini file for your PHP command line settings, you should also be able to debug just by running the script on the guest machine, e.g. php /var/www/mysite/foo.php

    enter image description here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥66 定制开发肯德基自动化网站下单软件
  • ¥20 vscode虚拟环境依赖包未安装
  • ¥15 odoo17关于owl开发js代码问题
  • ¥15 光纤中多普勒频移公式的推导
  • ¥15 怎么制作一个人脸识别门禁系统
  • ¥20 大华dss监控平台网络关闭登不进去
  • ¥15 请使用蚁群算法解决下列问题,并给出我完整的代码
  • ¥20 关于php录入完成后,批量更新数据库
  • ¥15 请教往复密封润滑问题
  • ¥15 cocos creator发布ios包