简体   繁体   English

Netbeans文件调试

[英]Netbeans file debugging

I have netbeans setup with xdebug so it can debug php. 我有netbeans设置与xdebug所以它可以调试PHP。 However, this only works if I create a php project. 但是,这只有在我创建一个php项目时才有效。 It will not work if I try opening a stand alone php file. 如果我尝试打开一个独立的php文件,它将无法正常工作。 So my question is, is it possible to debug a stand alone php file which is not part of a netbeans php project? 所以我的问题是,是否可以调试一个独立的php文件,它不是netbeans php项目的一部分?

If that is not possible, how do I debug stand alone php files with netbeans? 如果那是不可能的,我如何使用netbeans调试独立的php文件?

Each project can have it's own configuration (you can have 1 project that has PHP5.4 interpreter, one the is PHP5.6, one that is a command line and another that is a web project), but if you configure a general PHP 5 Interpreter: 每个项目都可以拥有自己的配置(你可以拥有一个拥有PHP5.4解释器的项目,一个是PHP5.6,一个是命令行,另一个是web项目)但是如果配置一般的PHP 5解释: PHP口译员

If you work on a windows machine you can use this code (filename is php.cmd) 如果您在Windows机器上工作,您可以使用此代码(文件名是php.cmd)

set XDEBUG_CONFIG="idekey=netbeans-xdebug"
@php.exe %* 

If you want to be able to debug, your interpreter should have the XDEBUG_CONFIG system variable and make sure it's connected to netbeans. 如果您希望能够进行调试,您的解释器应该具有XDEBUG_CONFIG系统变量并确保它已连接到netbeans。 You should set this to the same value in your Debbugging section of the PHP's config: 您应该在PHP的配置的Debbugging部分Debbugging其设置为相同的值: xdebug键

Next thing - if you right click inside the editor you will have the Debug File option, and a prompt window will pop: 接下来 - 如果您在编辑器中右键单击,您将拥有Debug File选项,并将弹出一个提示窗口:

运行参数 You don't really need anything here. 你真的不需要任何东西。 Just hit the "OK" button. 只需点击“确定”按钮即可。

As you can see, this final result is debug session of the t1.php file within c:\\TEMP\\ (which is not a working project): 如您所见,最终结果是c:\\TEMP\\中的t1.php文件的调试会话(这不是一个工作项目):

调试会话

No, There is none that I am aware of. 不,我没有意识到这一点。

As Myrddin mentioned the debugger needs some configurations that is a part of netbeans project. 正如Myrddin所说,调试器需要一些配置,这是netbeans项目的一部分。

but the best way you can debug a single file is to copy it on a project folder, and click the debug project, once the debug session is set then you can browse the PHP File that you want to debug and it will actually go through xdebug. 但是调试单个文件的最佳方法是将其复制到项目文件夹中,然后单击调试项目,一旦设置了调试会话,您就可以浏览要调试的PHP文件,它实际上将通过xdebug 。

Good Luck! 祝好运!

Short answer: CTRL + SHIFT + F5 简答:CTRL + SHIFT + F5

You can find the answer here: https://blogs.oracle.com/netbeansphp/entry/run_file_without_project 你可以在这里找到答案: https//blogs.oracle.com/netbeansphp/entry/run_file_without_project

I'm not entirely sure, but I think it is not possible, because you need some configuration to get the debugging working, and this configuration is part of a project. 我不完全确定,但我认为这是不可能的,因为您需要一些配置来使调试工作,并且此配置是项目的一部分。

You can always use print_r and var_dump to debug a single file. 您始终可以使用print_r和var_dump来调试单个文件。 But that is probably not the answer you're looking for. 但这可能不是您正在寻找的答案。

xdebug is very heavy and old tool you can use Kint php debuger here. xdebug是非常沉重的旧工具,你可以在这里使用Kint php debuger。

its free, so you can download Here 它是免费的,所以你可以在这里下载

it's pretty replacement for var_dump(), print_r() and debug_backtrace(). 它完全取代了var_dump(),print_r()和debug_backtrace()。

you need to add kint.class.php file using include or require function. 你需要使用include或require函数添加kint.class.php文件。

require '/kint/Kint.class.php';

that's it. 而已。

and you can use like 你可以使用喜欢的

########## DUMP VARIABLE ###########################
Kint::dump($GLOBALS, $_SERVER); // pass any number of parameters
// or simply use d() as a shorthand:
d($_SERVER);
########## DEBUG BACKTRACE #########################
Kint::trace();

more help is available on https://github.com/raveren/kint/

Good Luck :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM