如何在 CakePHP 上安装 DebugKit [英] How to Install DebugKit on CakePHP
问题描述
我正在学习如何使用 CakePHP
并且我配置一切正常,但是现在,我收到此警告:
I'm learning how to work with CakePHP
and I configured everything allright, but now, I get this warning:
DebugKit 未安装.它将帮助您检查和调试应用程序的不同方面.你可以从github安装
我已经点击了该链接并下载了该应用程序,但我不知道将这些文件夹放在哪里...我使用 EasyPhp 作为我的网络主机.
另外这里我按照步骤操作,
还有:
I already clicked on that link, and downloaded that app, but I have no idea where to place these folders... I'm using EasyPhp as my web host.
Also Here I followed the steps,
and there is:
`Ensure the plugin is loaded in app/Config/bootstrap.php by calling CakePlugin::load('DebugKit');`
但是我不知道如何调用
这里的东西,有提示吗?
But I don't know how to call
something here, is there a prompt ?
推荐答案
如何为 CakePHP 安装 DebugKit(只需 4 个简单的步骤!):
第 1 步(选项 A):传统/下载方法:
在您的 app/Plugin
目录中创建一个 DebugKit
文件夹,并将下载的内容放入其中(不是顶级文件夹 - 里面的东西).如果您知道如何从 github 克隆,那也可以正常工作.
Create a DebugKit
folder within your app/Plugin
directory, and put the contents of the download into it (not the top-level folder - the stuff within it). If you know how to clone from github, that works fine also.
步骤 1(选项 B):Composer 方法
这似乎是目前最受欢迎的选项(并且有充分的理由).如果您已经在使用 Composer [在此处了解更多信息],那么添加 DebugKit 非常简单.如果您以前从未使用过 Composer,请不要担心 - 只需使用上面的选项 A"即可.最终结果是一样的,而且也很容易.
This seems to currently be the most popular option (and for good reason). If you're already using Composer [find out more about it here], then adding DebugKit is crazy-simple. If you haven't used Composer before, don't worry - just use "option A" above. The end-result is the same, and it's easy too.
确保 composer.json 中存在 require.这将安装插件到 Plugin/DebugKit:
Ensure require is present in composer.json. This will install the plugin into Plugin/DebugKit:
{
"require": {
"cakephp/debug_kit": "2.2.*"
}
}
<小时>
第 2 步:
然后,在您的 app/Config/bootstrap.php
中,添加(或取消注释)以下行:
Then, in your app/Config/bootstrap.php
, add (or un-comment) the following line:
CakePlugin::load('DebugKit');
最后,在您的 app/Controller/AppController.php
文件(在类中)中,添加:
Lastly, in your app/Controller/AppController.php
file (within the class), add:
public $components = array(
'DebugKit.Toolbar'
);
(如果你已经有一个 $components
数组,那么只需添加到它 - 不要重新设置它.)
(If you already have a $components
array, then just add to it - don't re-set it.)
第 3 步:确保 debug 为 1 或更多
在您的 Config/core.php
文件中,确保这一行:
In your Config/core.php
file, make sure this line:
Configure::write('debug', 2);
值为 1 或 2.(在此处阅读有关调试模式的更多信息)
第 4 步:删除 sql_dump
:
在您的布局文件中,删除sql_dump"元素(在默认布局的底部)
In your layout file, remove the 'sql_dump' element (at the bottom of the default layout)
根据 debugKit 页面上的安装"部分:
According to the "Installation" section on the debugKit page:
- 克隆/复制此目录中的文件到 app/Plugin/DebugKit 中
- 通过调用 CakePlugin::load('DebugKit'); 确保插件已加载到 app/Config/bootstrap.php 中;
- 在 AppController.php 中包含工具栏组件:public $components = array('DebugKit.Toolbar');
- 将调试模式设置为至少 1.
- 如果您想体验令人敬畏的调试工具包 SQL 日志,请确保从您的布局中删除sql_dump"元素.
我怎么知道它是否有效?
您应该会在网站右上角的灰色方块上看到一个小图标.单击此选项以展开选项,然后单击一个选项以开始出色.
You should see a small icon on a gray square in the upper right corner of your site. Click on this to expand the options, then click on an option to start being awesome.
这篇关于如何在 CakePHP 上安装 DebugKit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!