Netbeans 中跨项目的 xdebug
情况是这样的..我在一个项目中有一些类...我的主要代码在另一个项目中...我将其分开,因为我使用 GIT 作为我的 SCM...所以当我调试我的主要代码时代码...我想进入这些类并调试它们,但是 xdebug 不会让我进入它们...我认为这是因为这些类位于另一个项目中...有什么想法吗?
提前致谢...
Here is the situation.. I have some classes that are in one project... My main code is in another project... and i split this up because i am using GIT as my SCM... So when i debug my main code... i would like to step into the classes and debug them, but xdebug won't let me step into them... and i assume its because the classes are in another project... any ideas?
Thanks in advance...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也遇到过这个。我将假设您的项目在部署时的外观是,单独项目中的类被复制到主代码中某处的某个目录中。
为了简单起见,我们假设单独的项目仅包含一个类
Foo
。我们还假设Foo
存在于目录和文件/maincode/external/lib/Foo.php
中部署的“主代码”中。最后,我们假设/maincode/external/lib
作为版本控制的“主代码”项目中的目录存在,并且它仅包含一个占位符文件,否则为空。首先,使用 git 提供的多种方法之一来忽略该项目的 NetBeans 项目目录中的
/maincode/external/lib
目录的内容。我们要让它看起来包含一些东西,并且我们不希望这个目录(否则应该是空的)错误地提交到它的更改。现在它已被忽略,请在该目录中创建一个到另一个项目中的 Foo.php 的符号链接。在 Unix 中,您需要 ln 命令,例如
在 Windows 中,您正在寻找 mklink 命令,例如
给 NetBeans 一两分钟的时间来考虑一下(或者强制通过调用“源”菜单中的“扫描外部更改”命令来解决此问题),您应该会看到
Foo.php
显示在您创建符号链接的“maincode”项目中。现在,当您跟踪执行并需要单步进入 Foo.php 以查看 Foo 类正在做什么时,您将单步进入“maincode”项目中的类。然而,由于它是指向“MyFooProject”项目中文件的符号链接,因此您所做的任何修改都将反映在那里。
只要确保取消链接所有内容(Unix 中的普通
rm
命令,以及 Windows 中常见的del
命令,但在符号链接所在的目录中!)通过。另外,如果您忽略的目录中存在您希望能够提交的内容,则取消忽略该目录。如果您需要对多个文件执行此操作,则可以链接整个目录。如果您通常将“MyFooProject”的内容复制到部署版本中的目录
/maincode/external/lib/myfoo/
中,而不是上述内容,那么只需像您所做的那样链接相应的目录即可上面的文件。例如,在 Windows 中,这将创建一个符号目录链接。我已经有一段时间没有在 Unix 上做过类似的事情了,所以我不记得在该操作系统上执行相同操作的确切命令(或者在 Unix 上是否可以使用符号目录链接)。链接目录后,您应该会看到新目录以及所有文件和子目录都显示在 NetBeans“主代码”项目中,为您的执行跟踪乐趣做好准备。
再次强调,完成后记得取消链接和取消忽略所有内容,以免第二天早上醒来时发现自己很困惑。 :) 要取消链接 Windows 中的目录...
它应该取消链接。 (当您删除和 rmdir'ing 时要小心,您正在对符号链接执行此操作!)
I've run into this as well. I am going to assume that the way your projects look when they are deployed is that the classes in the separate project are copied into some directory somewhere in the main code.
Let's assume the separate project contains only one class,
Foo
, for simplicity's sake. Let's assume, too, thatFoo
is present in the deployed "main code" in the directory and file/maincode/external/lib/Foo.php
. Finally, let's assume that/maincode/external/lib
exists as a directory in your version-controlled "main code" project, and that it contains only a place-holder file and is otherwise empty.First, use one of the many methods git provides to ignore the contents of the
/maincode/external/lib
directory in your NetBeans project directory for that project. We're going to make it look like it contains some stuff, and we don't want this directory, that is otherwise supposed to be empty, to get changes committed to it by mistake.Now that it is ignored, make a symbolic link in that directory to
Foo.php
over in the other project. In Unix, you want theln
command, e.g.In Windows, you are looking for the
mklink
command, e.g.Give NetBeans a moment or two to think about it (or force the issue by invoking the "Scan for external changes" command in the "Source" menu), and you should see
Foo.php
show up in the "maincode" project where you made the symbolic link.Now, when you are tracing through execution and need to step into Foo.php to see what the Foo class is doing, you will step into the one that is in the "maincode" project. Since it is a symbolic link over to the file in the "MyFooProject" project, however, any chanes you make will be reflected over there.
Just be sure to unlink everything (the normal
rm
commmand in Unix, and the usualdel
command in Windows, but in the directory where the symbolic link is!) when you are through. Also, if there were things in the directory that you ignored that you want to be able to commit, then un-ignore that directory.If you need to do this for more than just one file, then you can link whole directories. If, instead of the above, you normally copy the contents of "MyFooProject" into the directory
/maincode/external/lib/myfoo/
in the deployed version, then just link the appropriate directory like you did the file above. In Windows, for example,That will make a symbolic directory link. It has been a while since I did anything like that on Unix, so I don't remember the exact command for the same thing on that OS (or if symbolic directory links are even possible on Unix). Once the directory is linked, you should see the new directory plus all of the files and subdirectories show up in your NetBeans "maincode" project, ready for your execution-tracing pleasure.
Again, remember to unlink and un-ignore everything once you are done, lest you wake up the next morning to find yourself confused. :) To unlink the directory in windows...
and it should unlink. (Just be careful when you are deleteing and rmdir'ing that you are doing it to the symbolic link!)