oscarjg/ladybug-bundle
Composer 安装命令:
composer require oscarjg/ladybug-bundle
包简介
Symfony2 bundle for Ladybug library (Simple and Extensible PHP Dumper)
README 文档
README
This bundle provides an easy and extensible var_dump/print_r replacement for Symfony2 projects, both in controllers or Twig templates. For example, with this bundle, the following is possible:
<?php class UserController extends Controller { public function userAction($username) { ladybug_dump($username); // or just ld($username) } }
{{ user.username|ladybug_dump }}
Getting as a result:
Installation
Step 1: Composer
Add the following line to the composer.json file:
{
"require": {
"raulfraile/ladybug-bundle": "~1.0"
}
}
To actually install Ladybug in your project, download the composer binary and run it:
wget http://getcomposer.org/composer.phar
# or
curl -O http://getcomposer.org/composer.phar
php composer.phar install
Step 2: Enable the bundle
Finally, enable the bundle in the kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new RaulFraile\Bundle\LadybugBundle\RaulFraileLadybugBundle(), ); }
Examples
It is possible to dump any variable, including arrays, objects and resources:
Dumping an array
<?php $var = array(1, 2, 3); ladybug_dump($var)
Dumping an object
<?php ladybug_dump($this->getRequest())
The same can be accomplished using the Twig filter ladybug_dump.
Helpers
The are 5 helpers that can be used in any controller:
ladybug_dump($var1[, $var2[, ...]]): Dumps one or more variables
ladybug_dump_die($var1[, $var2[, ...]]): Dumps one or more variables and
terminates the current script
ladybug_dump_return($format, $var1[, $var2[, ...]]): Dumps one or more variables and
returns the dump in any of the following formats:
- yml: Returns the dump in YAML
- json: Returns the dump in JSON
- xml: Returns the dump in XML
- php: Returns the dump in PHP arrays
ladybug_dump_ini([$extension]): Dumps all configuration options
ladybug_dump_ext(): Dumps loaded extensions
There are also some shortcuts in case you are not using this function names:
ld($var1[, $var2[, ...]]): shortcut for ladybug_dump
ldd($var1[, $var2[, ...]]): shortcut for ladybug_dump_die
ldr($format, $var1[, $var2[, ...]]): shortcut for ladybug_return
Only ladybug_dump can be used inside Twig templates.
Symfony profiler integration
Instead of printing out the dump tree inside the HTML document, you can use the Ladybug logger and see the results in a tab of the Symfony profiler:
To make use of the Ladybug logger, grab the ladybug service from the DIC, and call the log
method:
<?php class TestController { public function testAction() { $var = 1; $this->get('ladybug')->log($var); }
API reference
Ladybug automatically detects Symfony, Doctrine, Twig, Silex and other classes, and link them to the official documentation.
Configuration
You can configure ladybug library directly in your config.yml file. Here are the defaults:
raul_fraile_ladybug: theme: modern # select the theme: base, modern or custom themes expanded: false # true to expand all the variables tree by default silenced: false # true to ignore all ladybug calls
Credits
- Raul Fraile (@raulfraile)
- All contributors
License
LadybugBundle is released under the MIT License. See the bundled LICENSE file for details.
oscarjg/ladybug-bundle 适用场景与选型建议
oscarjg/ladybug-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 206 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 06 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「tree」 「twig」 「dump」 「ladybug」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 oscarjg/ladybug-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 oscarjg/ladybug-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 oscarjg/ladybug-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package will add the `dd` and `dump` helpers to your Phalcon application.
Shoot aims to make providing data to your templates more manageable
Simple Twig extension improving templates debugging
nice output for debug functions for PHP 5.3
This Symfony bundle integrates PhpSpreadsheet into Symfony using Twig.
A Twig extension to insert css as inline styles with a tag
统计信息
- 总下载量: 206
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-06-14




