wp-cli / doctor-command
通过运行一系列检查,诊断WordPress中的问题。
Requires
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-05 20:51:06 UTC
README
通过运行一系列检查,诊断WordPress中的问题。
概述
wp doctor
允许您轻松运行一系列可配置的检查,以诊断WordPress的问题。
没有 wp doctor
,您的团队必须依靠记忆手动调试问题。有了 wp doctor
,您的团队可以通过将诊断程序编码为一系列WP-CLI运行的检查来节省数小时,以识别WordPress安装的健康状况。wp doctor
默认自带数十项检查,并支持自定义的 doctor.yml
文件,以定义对您最重要的检查。
每个检查都包括名称、状态("成功"、"警告"或"错误")和可读消息。例如,cron-count
是一个检查,以确保WP Cron没有因工作而爆炸
$ wp doctor check cron-count
+------------+---------+--------------------------------------------------------------------+
| name | status | message |
+------------+---------+--------------------------------------------------------------------+
| cron-count | success | Total number of cron jobs is within normal operating expectations. |
+------------+---------+--------------------------------------------------------------------+
想要将结果导入到另一个系统?使用 --format=json
或 --format=csv
以机器可读的格式呈现检查。
wp doctor
设计为可扩展。创建自定义的 doctor.yml
文件,以定义您认为对系统必要的额外检查
plugin-w3-total-cache:
check: Plugin_Status
options:
name: w3-total-cache
status: uninstalled
然后,使用 --config=<file>
参数运行自定义的 doctor.yml
文件
$ wp doctor check --fields=name,status --all --config=doctor.yml
+-----------------------+--------+
| name | status |
+-----------------------+--------+
| plugin-w3-total-cache | error |
+-----------------------+--------+
一起运行所有检查,wp doctor
是获取WordPress安装高级概述的最快方式。
使用
此包实现了以下命令
wp doctor
诊断WordPress的问题。
wp doctor
示例
# Verify WordPress core is up to date.
$ wp doctor check core-update
+-------------+---------+-----------------------------------------------------------+
| name | status | message |
+-------------+---------+-----------------------------------------------------------+
| core-update | warning | A new major version of WordPress is available for update. |
+-------------+---------+-----------------------------------------------------------+
# List checks to run.
$ wp doctor list
+----------------------------+--------------------------------------------------------------------------------+
| name | description |
+----------------------------+--------------------------------------------------------------------------------+
| autoload-options-size | Warns when autoloaded options size exceeds threshold of 900 kb. |
| constant-savequeries-falsy | Confirms expected state of the SAVEQUERIES constant. |
| constant-wp-debug-falsy | Confirms expected state of the WP_DEBUG constant. |
| core-update | Errors when new WordPress minor release is available; warns for major release. |
wp doctor check
运行一系列检查以诊断WordPress中的问题。
wp doctor check [<checks>...] [--all] [--spotlight] [--config=<file>] [--fields=<fields>] [--<field>=<value>] [--format=<format>]
检查是针对WordPress某个范围进行的常规运行,报告"状态"和"消息"。状态可以是"成功"、"警告"或"错误"。消息是对状态的易读解释。如果任何检查失败,则命令将以代码 1
退出。
选项
[<checks>...]
Names of one or more checks to run.
[--all]
Run all registered checks.
[--spotlight]
Focus on warnings and errors; ignore any successful checks.
[--config=<file>]
Use checks registered in a specific configuration file.
[--fields=<fields>]
Limit the output to specific fields.
[--<field>=<value>]
Filter results by key=value pairs.
[--format=<format>]
Render results in a particular format.
---
default: table
options:
- table
- json
- csv
- yaml
- count
---
可用字段
这些字段将默认显示在每个检查中
- name
- status
- message
示例
# Verify WordPress core is up to date.
$ wp doctor check core-update
+-------------+---------+-----------------------------------------------------------+
| name | status | message |
+-------------+---------+-----------------------------------------------------------+
| core-update | warning | A new major version of WordPress is available for update. |
+-------------+---------+-----------------------------------------------------------+
# Verify the site is public as expected.
$ wp doctor check option-blog-public
+--------------------+--------+--------------------------------------------+
| name | status | message |
+--------------------+--------+--------------------------------------------+
| option-blog-public | error | Site is private but expected to be public. |
+--------------------+--------+--------------------------------------------+
wp doctor list
列出要运行的所有可用检查。
wp doctor list [--config=<file>] [--fields=<fields>] [--format=<format>]
选项
[--config=<file>]
Use checks registered in a specific configuration file.
[--fields=<fields>]
Limit the output to specific fields.
[--format=<format>]
Render output in a specific format.
---
default: table
options:
- table
- json
- csv
- count
---
可用字段
这些字段将默认显示在每个检查中
- name
- description
示例
# List checks to run.
$ wp doctor list
+----------------------------+--------------------------------------------------------------------------------+
| name | description |
+----------------------------+--------------------------------------------------------------------------------+
| autoload-options-size | Warns when autoloaded options size exceeds threshold of 900 kb. |
| constant-savequeries-falsy | Confirms expected state of the SAVEQUERIES constant. |
| constant-wp-debug-falsy | Confirms expected state of the WP_DEBUG constant. |
| core-update | Errors when new WordPress minor release is available; warns for major release. |
安装
安装此包需要WP-CLI v2.1或更高版本。使用 wp cli update
更新到最新稳定版本。
完成此操作后,您可以使用以下命令安装此包的最新稳定版本
wp package install wp-cli/doctor-command:@stable
要安装此包的最新开发版本,请使用以下命令代替
wp package install wp-cli/doctor-command:dev-main
贡献
我们感谢您主动为这个项目做出贡献。
贡献不仅限于代码。我们鼓励您以最适合您能力的方式做出贡献,例如编写教程、在当地聚会中演示、帮助其他用户解决支持问题或修订我们的文档。
为了获得更详细的介绍,请查看WP-CLI的贡献指南。本软件包遵循那些政策和指南。
报告一个错误
认为你发现了一个错误?我们非常乐意你帮助我们将其修复。
在创建新问题之前,你应该搜索现有问题,看看是否有现成的解决方案,或者它是否已在较新版本中修复。
经过一番搜索后,发现你的错误没有开放或已修复的问题,请创建一个新问题。尽可能提供详细信息,并在可能的情况下提供重现步骤。如需更多指导,请查看我们的错误报告文档。
创建一个拉取请求
想要贡献一个新功能?请首先打开一个新问题,讨论这个功能是否适合本项目。
一旦你决定投入时间来确保你的拉取请求能够完成,请遵循我们创建拉取请求的指南,确保它是一个愉快的体验。有关在本地工作于此软件包的详细信息,请参阅"设置"。
此README.md文件是使用wp scaffold package-readme
(文档)从项目代码库动态生成的。若要提出建议,请提交针对代码库相应部分的拉取请求。