Aptana在Vagrant上调试php Xdebug



我如何为托管在流浪盒上的项目设置调试(PHP)?

幸运的是,这并不是那么困难

注意

我不是在Aptana Studio 3中开发的,所以也许还有另一种(更好的)方法可以实现这一目标。我刚刚下载了它,玩了它并让它努力帮助您。

vm xdebug设置

首先确保您正确安装了Xdebug在VM上。

运行

php -v

查看信息,它应该显示这样的东西

PHP 5.5.8 (cli) (built: Jan  9 2014 08:14:44) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

或运行

php -m

并在列表中搜索Xdebug。

接下来编辑php.ini文件,并确保文件中存在以下行

zend_extension="{PATH TO THE XDEBUG module}" <-- run a simple find /. -name xdebug.so if you are not sure where to find it
xdebug.remote_enable=1 
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.remote_connect_back= 1
xdebug.remote_log="/tmp/xdebug.log"

保存文件并确保重新启动Apache Service

vagrantfile设置

您必须确保的下一件事是您的VagrantFile包含以下行

config.vm.network :private_network, ip: "22.22.22.11"

最好的解释这是从流浪网站上

专用网络允许您通过某些无法从全球互联网公开访问的地址访问客人。通常,这意味着您的机器在私人地址空间中获取地址。

主机设置

您要做的最后一件事是用以下行编辑主机文件

22.22.22.11 dev.local <-- Just an example name, make it anything you link

现在,您可以通过打开浏览器并转到Dev.Local

来加速VM。

Aptana Studio 3设置

转到窗口 - &gt;显示视图 - &gt;服务器。添加"外部Web服务器"

Name: Anything you like
Base Url: http://dev.local
Document Root: Browse to your vagrant shared project folder and then select the document root as you specified inside your vhosts config on the VM
Run Command: Leave it empty
Stop Command: Leave it empty

单击确定并返回您的窗口 - &gt;显示视图 - &gt;Project Explorer

选择要调试的文件设置一些断点,然后运行 - &gt;调试为 - &gt;PHP服务器如果提示您使用对话框显示路径,则必须将其更正到http://dev.local

就是这样!您正在调试

最新更新