PHP:分析代码和严格的环境〜改进我的编码

发布于 2024-09-05 19:46:59 字数 938 浏览 4 评论 0原文

我想更新我的本地工作环境,使其更加严格,以改进我的代码。我知道我的代码没问题,但与大多数事情一样,总是有改进的空间。

为了简单起见,我在本地计算机上使用 XAMPP Apache Friends XAMPP(基本包)版本 1.7.2 因此,我将我的 php.ini : error_reporting 更新为 <代码>E_ALL | E_STRICT 帮助制定代码标准。我还启用了 XDebug 扩展 zend_extension = "C:\xampp\php\ext\php_xdebug.dll" ,它似乎正在工作,测试了一些损坏的代码并得到了很好的标准橙色错误通知。

然而,读完这个问题后,分析 PHP 代码并启用了探查器,我似乎无法创建cachegrind 文件。

我看过的许多指南似乎都认为您需要在 XAMPP 中安装 XDebug,这让我认为它们已经过时了,因为现在 XDebug 与 XAMPP 捆绑在一起。

因此,如果有人能帮助我指明正确的方向,配置 XDebug 来输出grind 文件,或者只是为 XAMPP 中的 XDebug 配置提供一组很好的默认设置,我将不胜感激。似乎可以继续的文档很少。

如果人们有关于将这些工具与 Netbeans 集成的提示,那就太棒了。

我很高兴收到有关其他事情的建议,这些建议可以帮助我在语法和性能方面加强我的 php 代码,

谢谢,并对漫无目的的问题表示歉意!

Ninja 编辑

我应该提到,我使用命名虚拟主机作为我的 Apache 配置,我认为这就是为什么在端口 9000 上运行 XDebug 对我不起作用。我想我需要编辑我的虚拟主机以包含端口 9000

I would like to update my local working environment to be stricter in an effort to improve my code. I know that my code is okay, but as with most things there is always room for improvement.

I use XAMPP on my local machine, for simplicities sake Apache Friends XAMPP (Basic Package) version 1.7.2 So I've updated my php.ini : error_reporting to be E_ALL | E_STRICT to help with the code standard. I've also enabled the XDebug extension zend_extension = "C:\xampp\php\ext\php_xdebug.dll" which seems to be working, having tested some broken code and got the nice standard orange error notice.

However, having read this question, Profiling PHP code and enabled the profiler, I cannot seem to create a cachegrind file.

Many of the guides that I've looked at seem to think you need to install XDebug in XAMPP which leads me to think they are out of date, as XDebug is bundled with XAMPP these days.

So I would appreciate it if anyone can help point me in the right direction with both configuring XDebug to output grind files, and or just a great set of default settings for the XDebug config in XAMPP. Seems there is very little documentation to go on.

If people have tips on integrating these tools with Netbeans, that would be awesomesauce.

I'm happy to get suggestions on other things that I can do to help tighten up my php code, both syntactically and performance wise

Thanks, and apologies for the rambling question(s)!

Ninja edit

I should menion that I'm using named vhosts as my Apache configuration, which I think is why running XDebug on port 9000 isn't working for me. I guess I'd need to edit my vhost to include port 9000

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那伤。 2024-09-12 19:46:59

如果您总是想运行探查器:

xdebug.profiler_enable  = 1

否则如果您想有选择地打开探查器(一件好事),请使用:

xdebug.profiler_enable_trigger  = 1

如果您正在触发,则需要使用 XDEBUG_PROFILE GET/POST 参数,或发送 cookie名称为 XDEBUG_PROFILE。有浏览器插件可以提供帮助;对于 Firefox,我使用 Xdebug Helper,但由于它似乎已经消失,您可以尝试 简单的 Xdebug

我发现默认的输出目录不起作用,所以尝试自己设置:

xdebug.profiler_output_dir  = /home/deebster/php/profiler

如果不使用 /tmp,请记住设置目录的权限以允许 Apache 创建文件

If you always want to run the profiler:

xdebug.profiler_enable  = 1

else if you want to selectively switch the profiler on (a good thing), use:

xdebug.profiler_enable_trigger  = 1

If you're triggering, you'll need to using the XDEBUG_PROFILE GET/POST parameter, or send a cookie with the name XDEBUG_PROFILE. There are browser add-ons to help; For Firefox I use Xdebug Helper, but as it seems to have disappeared you could try easy Xdebug.

I found that the default output dir didn't work, so try setting it yourself:

xdebug.profiler_output_dir  = /home/deebster/php/profiler

Remember to set the directory's permissions to allow Apache to create files if you don't use /tmp

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文