4spacesdk/ci4debugtool
最新稳定版本:1.0.8
Composer 安装命令:
composer require 4spacesdk/ci4debugtool
包简介
Debug Tool for CodeIgniter 4
README 文档
README
Debug tool for Code Igniter 4
Usage
Add a debug message
Data::debug("Some debug message");
Almost everything can be thrown to Data::debug; simple types, arrays, objects, Entities.
Or set a variable
Data::set("name", $someThing);
Variable can be a simple type or an Entity of OrmExtension. Data will use toArray or allToArray on Entity if supplied by OrmExtension.
Use Data::getStore() to get the data and present it. Ex. In your base controller add this in the constructor
Data::set('bench', 0); timer('code-start');
Create a method to print response. Ex
protected function success($code = 200) { $this->response->setStatusCode($code); Data::set('bench', timer()->getElapsedTime('code-start')); $this->response->setJSON(Data::getStore()); $this->response->send(); }
This will give you a nice benchmark on every json response.
Live Template
For fast debugging, add this Live Template to your IDE: Data::debug(get_class($this), "$END$");.
Code Igniter 4 Error page
To see the debug data in Code Igniter 4 Error page follow these steps
1
Edit app/Views/errors/html/error_exception.php and add a tab for Data in the list with id #tabs.
<li><a href="#data">Data</a></li>
2
In the same file add this section under the div with class .tab-content.
<!-- Data --> <div class="content" id="data"> <pre><code><?=json_encode(\DebugTool\Data::getStore(), JSON_PRETTY_PRINT)?></code></pre> </div>
3 Optional
To top is all up. Go to app/Views/errors/debug.js and add this at the bottom of init()-function
// Show last selected tab if(window.localStorage.getItem('lastTab')) { tabLinks[window.localStorage.getItem('lastTab')].click(); }
And add this to showTab()-function
window.localStorage.setItem("lastTab", selectedId);
This will remember the tab between page reload.
统计信息
- 总下载量: 17.39k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-12-04