foolz/profiler 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

foolz/profiler

Composer 安装命令:

composer require foolz/profiler

包简介

monolog-based profiler

README 文档

README

This package provides a simple to use profiler, with the power of monolog.

Requirements

  • PHP 5.4 or higher
  • Monolog (automatically installed with composer)

Installation

Install as any composer package.

Setup

You should load the profiler early in your code.

<?php
$profiler = new Profiler();
$profiler->enable();

Until enable isn't run, no request will be logged. You can setup monolog handlers to have custom output options:

<?php
$profiler = new Profiler();
$profiler->pushHandler(new ChromePHPHandler());
$profiler->enable();

$profiler->log("Profiler enabled");

HTML output

Remember to check whether you have a text/html request before inserting the HTML profiler panel.

You can print the current log at any time with $profiler->getHtml().

If you use a framework you might have a $response variable that handles the data sent to the client. To put the profiler at the bottom of the page, you may try something similar to the following.

<?php
$content = explode('</body>', $response->getContent());
if (count($content) == 2) {
    $response->setContent($content[0].$this->profiler->getHtml().$content[1]);
}

$response->send();

Methods

  • pushHandler() As Monolog's pushHandler() function, allows adding log handlers to the logger

  • getLogger() Returns the Monolog logger so it can be customized

  • enable() Enables the profiler and prints how much time was elapsed since the start of the script

  • isEnabled() Tells if the profiler is enabled

  • log($string, $context) Logs elapsed time since the beginning of the script and total memory usage The $string variable allows setting a string to identify the entry in the log The $context variable allows adding arbitrary data to the entry

  • logMem($string, $variable, $context) Logs memory usage of $variable. While checking, a clone of $variable will be created (it can't be helped), so use with caution. For the rest, it works like log()

  • logStart($string, $context) Like log() but it starts a timer

  • logStop($string, $context) Like log(), but if called after logStart(), $context will contain elapsed time

  • getHtml() Returns an HTML representation of the logged entries

统计信息

  • 总下载量: 12.38k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2013-06-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固