lemmon/cl 问题修复 & 功能扩展

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

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

lemmon/cl

最新稳定版本:v1.1.0

Composer 安装命令:

composer require lemmon/cl

包简介

Console logger for PHP that dumps cleanly to stdout, keeping HTTP responses intact while showing rich variable details.

README 文档

README

A simple PHP console logger for local development and debugging, providing beautiful and detailed variable inspection. Particularly useful when working with PHP's built-in development server. During HTTP requests, dumps are automatically redirected to stdout, keeping your responses clean while still providing detailed debugging information.

CL Console Output

Why use CL?

  • Clean HTTP Responses: Unlike var_dump() or print_r(), cl() sends its output directly to your terminal (stdout), ensuring your browser's HTTP response remains clean and unaffected. This is invaluable when debugging APIs, JSON responses, or simply keeping your HTML output pristine.
  • Detailed & Beautiful Output: Leveraging Symfony's VarDumper component, cl() provides highly detailed, syntax-highlighted, and easily readable dumps of any PHP variable type, from simple strings to complex objects and arrays.
  • Non-Blocking Execution: cl() dumps the variable and allows your script to continue execution, unlike dd() (dump and die) functions that terminate the script immediately.
  • Lightweight & Zero Configuration: Just install and use. No complex setup or configuration files needed.
  • Framework Agnostic: Works in any PHP project, regardless of the framework you're using.

Note

cl is a lightweight "dump-and-continue" helper for quick inspections, whereas Xdebug handles step-debugging, profiling, and coverage—reach for the one that fits the task.

Installation

composer require lemmon/cl --dev

Tip

Install the package as a dev dependency (composer require --dev) so production builds stay lean.

Usage

<?php

require 'vendor/autoload.php';

// Dump any variable to console
$data = ['hello' => 'world'];
cl($data);

// Works with any PHP type
cl(new stdClass());
cl(42);
cl("Hello World");

Note

The helper wraps Symfony's VarDumper, so any type VarDumper supports works automatically.

Quick Example

Want to try it out? Clone this repository and run:

composer install
composer example

Then open your browser and navigate to http://localhost:8000. You'll see a simple message in your browser, but the real magic happens in your console where you'll see a beautifully formatted dump of various data types.

Running Tests

Run composer test to execute the PHPUnit suite and confirm the helper remains functional.

Features

  • Beautiful console output with syntax highlighting
  • Detailed variable inspection
  • Works with any PHP type
  • Zero configuration needed
  • Lightweight and simple to use
  • Debug output appears in your terminal, not in the browser
  • Keeps HTTP responses clean while debugging

Requirements

  • PHP 7.4 or higher

License

This package is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-21