用Laravel Homestead进行PhpStorm调试不起作用 [英] PhpStorm debug with Laravel Homestead not working

查看:140
本文介绍了用Laravel Homestead进行PhpStorm调试不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将PhpStorm设置为在Vagrant Homestead环境中正确调试. Xdebug已正确安装,并且我正在运行PHP 7.1

在我的应用中设置断点后,脚本会通过任何断点,并且我收到以下消息:

debug session was finished without being paused
        It may be caused by path mappings misconfiguration or not synchronized local and remote projects.
        To figure out the problem check path mappings configuration for 'wedleague.loc' server at PHP|Servers or enable Break at first line in PHP scripts option (from Run menu).

我已经检查了映射,并将其设置为项目的根:

local path                              remote path
file://C:/vagrant/projects/wedleague    /home/vagrant/code/wedleague

如果我设置在第一个断点进行调试,则可以完成调试会话.

这里尝试了很多答案,但似乎无济于事.

我该如何尝试使调试会话正常工作?

更新: 我也尝试过这种映射(如建议的那样)

file://C:/vagrant/projects/wedleague/public /home/vagrant/code/wedleague/public

仍然不能使用此配置:(

解决方案

步骤1

安装PHPStorm 2017.X

为Chrome安装Xdebug帮助程序

步骤2

通过ssh(选择腻子,WinSCP,MobaXterm等工具) 安装xdebug,您的情况下laravel在Nginx默认情况下默认为 Ubuntu 16.04 ,因此我们需要遵循这些说明 我使用的值是

; Enable xdebug extension module
zend_extension=/usr/lib64/php/modules/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
xdebug.remote_host=10.0.2.2

/etc/php.d/xdebug.ini

但是请注意,我将自己的vagrant安装(宅基地基于Vagrant)与CentOS和apache一起使用.更改配置后,重新启动虚拟机.

vagrant / homestead halt

然后重新开始

vagrant / homestead up

步骤3

通过右键单击符号>选项来配置chrome中的Xdebug帮助程序扩展,然后在下拉菜单中将 IDE键设置为PHPStorm.

像很多一样配置PHPStorm

提示:设置具有快捷键ctrl + alt + s

检查以下设置.不要忘记在服务器设置中同时添加http和https,最重要的是,请不要阅读路径映射部分.

最后但并非最不重要的一点是单击这些按钮,在我看来,带有手机号角的第一个按钮实际上已颠倒了图标:调试时,它应该具有绿色的小部分,从逻辑上讲,红色表示停止,现在表示启动. /p>

按钮2在查询字符串中以会话var开头您的网址!

P.s.来自您的问题:我认为您需要将laravel的根目录上移1级,而不是公用文件夹

我刚刚在家安装了宅基,它附带了xdebug:

I'm trying to setup PhpStorm to debug correctly within a Vagrant Homestead environment. Xdebug is correctly installed and I'm running PHP 7.1

After setting a breakpoint in my app the script passes through any breakpoints and I get this message:

debug session was finished without being paused
        It may be caused by path mappings misconfiguration or not synchronized local and remote projects.
        To figure out the problem check path mappings configuration for 'wedleague.loc' server at PHP|Servers or enable Break at first line in PHP scripts option (from Run menu).

I've checked the mappings and have this set up for the root of the project:

local path                              remote path
file://C:/vagrant/projects/wedleague    /home/vagrant/code/wedleague

If I set to debug at first breakpoint I can work through the debug session.

Tried loads of answers here but nothing seems to work.

What can I try to get the debug session to work correctly?

Update: I've also tried this mapping (as suggested)

file://C:/vagrant/projects/wedleague/public /home/vagrant/code/wedleague/public

Still not working with this configuration either :(

解决方案

Step 1

Install PHPStorm 2017.X

Install Xdebug helper for chrome

Step 2

Via ssh (choose a tool like putty, WinSCP, MobaXterm etc.) Install xdebug, in your case laravel gets Ubuntu 16.04 by default with Nginx so we need to follow these instructions The values I used are

; Enable xdebug extension module
zend_extension=/usr/lib64/php/modules/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
xdebug.remote_host=10.0.2.2

in /etc/php.d/xdebug.ini

But note that I use my own vagrant installation (homestead is based on Vagrant) with CentOS and apache instead. Restart your virtual machine after config changes.

vagrant / homestead halt

and start again

vagrant / homestead up

Step 3

Config Xdebug helper extension in chrome by right clicking the symbol > options and set your IDE key to PHPStorm in the dropdown menu.

Configure PHPStorm, like a lot

hint: Settings has the shortcut ctrl + alt + s

Check the following settings. Don't forget to add both http and https in the Servers Setting and most important, don't read over the path mappings part.

And last but not least click these buttons, the first button with the phone horn actually has reversed icons in my opinion: when debugging it should have the little green part, altough logically red would mean stop, now it means start.

button 2 starts your url with a session var in the query string!

P.s. from your question: I think you need to go 1 level up root of laravel instead of public folders

edit: I just installed homestead at home and it comes with xdebug installed:

这篇关于用Laravel Homestead进行PhpStorm调试不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆