承接 xethron/l4-to-string 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

xethron/l4-to-string

Composer 安装命令:

composer require xethron/l4-to-string

包简介

Laravel 4 version of xethron/to-string, which adds query and queryLog to string functions.

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

Logging variables can sometimes cause huge logs, especially if you want to email those logs to yourself.

On the other hand, logging exceptions with the default __toString can will most likely give you just enough information to confuse the hell out of you!

This class extends Xethron\ToString, and in addition, adds a few Laravel 4 specific functions for converting Query Logs to Strings.

Variable to String

This is a function that will display a variable similar to print_r, with the ability to specify the max_lines, max_depth (for arrays) and min_depth (for arrays).

This means that you will never get an email with an array 3000 lines long as you would with print_r.

Xethron\L4ToString::variable( $var, $max_lines, $max_depth, $min_depth )

I recommend adding a global function to one of your startup files for easier access:

function varToStr( $var, $max_lines = 10, $max_depth = 4, $min_depth = 2 )
{
    return Xethron\L4ToString::variable( $var, $max_lines, $max_depth, $min_depth );
}

Exception to String

This converts an Exception to string, much like PHP's __toString, however, it won't cut off those important pieces of information you require while debugging.

On top of that, it also uses the Variable to String to to include all the variables passed in the Stack Trace.

Two functions are available:

Xethron\L4ToString::exception( $e ); // This will print out the entire Exception

Xethron\L4ToString::trace( $e->getTrace() ); // This will only print out the stack trace

Query Log to String

This will convert the Laravel 4 Query Log to a neat Query String like:

#0 select * from `table` where `table`.`id` = 113 and `deleted` = 0 limit 1;
    {"bindings":[113,0],"time":1.08}
#1 select * from `another_table` where `another_table`.`deleted_at` is null and `id` = '66' limit 1;
	{"bindings":["66"],"time":0.49}
#2 select * from `country` where `country`.`deleted` = 0 and `country`.`name` in ('South Africa');
	{"bindings":[0,"South Africa"],"time":0.51}

Two Functions are available:

Xethron\L4ToString::queryLog(); // gets the latest query log and prints it Xethron\L4ToString::queryLog( \DB::getQueryLog() ); // Specify your own query log Xethron\L4ToString::query( $qyery ); // Pass a single query from the query log to be converted to string

License

L4ToString is distributed under the terms of the GNU General Public License, version 3 or later.

xethron/l4-to-string 适用场景与选型建议

xethron/l4-to-string 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17.38k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2014 年 02 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「convert」 「string」 「print_r」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 xethron/l4-to-string 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 xethron/l4-to-string 我们能提供哪些服务?
定制开发 / 二次开发

基于 xethron/l4-to-string 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL
  • 更新时间: 2014-02-01