如何在 PhpStorm 中为在 Vagrant 中运行的 Laravel Web 应用程序正确设置 XDebug?(Mac OS X)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22484304/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 09:12:57  来源:igfitidea点击:

How to setup XDebug properly in PhpStorm for Laravel web app that run in Vagrant? (Mac OS X)

phpapachelaravelvagrantphpstorm

提问by X Sham

I have my Laravel web app run inside Vagrant, using precise64box.

我使用precise64box在 Vagrant 中运行我的 Laravel Web 应用程序。

In vagrant box: in directory /etc/apache2/sites-available, I have 000-default.confand laratest.conffile. I'm only interested in laratest.confright now.

在流浪箱中:在目录中/etc/apache2/sites-available,我有000-default.conflaratest.conf文件。我只对laratest.conf现在感兴趣。

Inside laratest.conf:

在 laratest.conf 中:

<VirtualHost *:80>
   ServerName laratest.dev
   ServerAlias www.laratest.dev
   ServerAdmin webmaster@localhost
   DocumentRoot /var/www/laratest/public

  <Directory /var/www/laratest/public>
    Options -Indexes +FollowSymLinks
    AllowOverride all
    Require all granted
  </Directory>     
</VirtualHost>

In my php.inifile from /etc/php5/apache2/directory:

在我的目录中的php.ini文件中/etc/php5/apache2/

[xdebug]
zend_extension="./usr/lib/php5/some-number/xdebug.so"
xdebug.default_enable=1
xdebug.remote_log="/var/log/xdebug/xdebug.log"
xdebug.idekey="vagrant"
xdebug.remote_enable=1
xdebug.profiler_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_autostart=1
xdebug.remote_connect_back=1

So, I access my laravel web with laratest.devurl

所以,我使用laratest.devurl访问我的 Laravel 网站

In PHPStorm -> Preferences -> Project Settings -> PHP -> Servers, the image below is my setup: enter image description here

PHPStorm -> Preferences -> Project Settings -> PHP -> Servers,下图是我的设置: 在此处输入图片说明

I already enable listener in PHP Debug Connection (Phone icon) and put a breakpoint. The breakpoint manage to hit when I run the web, but it give this error: enter image description here

我已经在 PHP 调试连接(电话图标)中启用了侦听器并放置了一个断点。当我运行网络时,断点设法命中,但它给出了这个错误: 在此处输入图片说明

Is there anything wrong with my set up? Especially mapping. I have tried so many things and googling, still can't debug properly yet

我的设置有问题吗?尤其是映射。我已经尝试了很多东西并谷歌搜索,仍然无法正常调试

回答by X Sham

It turns out this is the correct mapping I needed to make it to works

事实证明,这是我使其正常工作所需的正确映射

enter image description here

在此处输入图片说明