1. 云栖社区>
  2. PHP教程>
  3. 正文

Viewing The PHP Debug Log

作者:用户 来源:互联网 时间:2017-12-01 09:41:11

Viewing The PHP Debug Log - 摘要: 本文讲的是Viewing The PHP Debug Log, When building web applications, especially with PHP, there are some tools that are invaluable. These include things l

When building web applications, especially with PHP, there are some tools that are invaluable.

These include things likea good IDE, a powerfuldebugger,version control, and so on. But one of the things that I think we often neglect against our shiny tools are basic text files.

No, I don’t think we need to take a step back from our usual toolset, let’s not forget files also at our disposal.

Case in point: Let’s say you’re working on a web application. If you’re using PHP, then one way to do this is to view the PHP debug log.

It’s a simple text file that gives you as much information as you could want about any page in your project.

The PHP Debug Log

Though the PHP debug log is available regardless of the type of project you’re working with.I’m going to be talking about viewing it within the context of a WordPress-based project.

Of course, right?

Since the majority of the posts that I share andwork I do is inMAMP, then I’m going to approach it from that angle.

1. Activate Logging

Just in case you haven’t configured PHP to log errors, then you need to make sure that you configure that first.

From the MAMP menu, find ‘Edit Template’and select the version foryour version of PHP.

Viewing The PHP Debug Log

When the template window appears, locate the lines that contain:

display_errors display_startup_errors log_errors

And make sure they are all uncommented. That is, make sure they are not preceded by a semicolon.

Viewing The PHP Debug Log This will activate logging. Restart MAMP (or Apache) depending on what you’re running.

2. Find Your Debug Log

If you’re working on a WordPress project, then you’re likely to find debug.log in the wp-content directory.

Viewing The PHP Debug Log

You can view this file with OS X’s Console application. Though it may be easier to peek at this file when something isn’t working as it should, I’ve found it easier to leave it open when developing.

Viewing The PHP Debug Log

That is, I leave it open along side my debugger, my IDE, version control, and my other tools. It helps to have as much information as necessary before committing code to the repository.

This doesn’t mean you’ll catch everything . I don’t. After all, it’s a lot of stuff to keep track of, but the more you make it part of your workflow, the more natural it becomes to keep it open and read it.

以上是云栖社区小编为您精心准备的的内容,在云栖社区的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索,以便于您获取更多的相关知识。