Download the PHP package jdz/output without Composer
On this page you can find all versions of the php package jdz/output. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package output
JDZ Output
A lightweight PHP library for handling process output with different verbosity levels and formatting options. Perfect for CLI applications, logging, and process monitoring.
Features
- Multiple output types: step, info, warn, error, and dump messages
- Dual storage system: Filtered output based on verbosity + complete message dump
- Verbosity control: Fine-grained filtering with hierarchical levels using PHP 8.1+ enums
- CLI detection: Automatically detects CLI environment and outputs to console
- File export: Save filtered or complete output to files for logging
- Tagged messages: All messages are automatically tagged and aligned
- String conversion: Access both filtered and complete output programmatically
- Type-safe: Uses backed enums for type safety and better IDE support
Installation
Install via Composer:
Requirements
- PHP >= 8.2
Quick Start
Verbosity Levels
The library uses a PHP 8.1+ backed enum for type-safe verbosity levels. All messages are always stored internally regardless of verbosity level.
Enum Cases
| Enum Case | Value | Description |
|---|---|---|
Verbosity::NONE |
0 | No messages in filtered output |
Verbosity::STEP |
1 | Only step messages |
Verbosity::ERROR |
4 | Step and error messages |
Verbosity::WARN |
8 | Step, error, and warning messages |
Verbosity::INFO |
16 | Step, error, warning, and info messages |
Verbosity::ALL |
32 | All messages including debug/dump |
Usage
Verbosity Hierarchy
Higher verbosity levels include all lower level messages:
Enum Methods
Message Types
The Output class provides methods for different types of messages, each tagged appropriately.
CLI Mode
The library automatically detects if it's running in CLI mode and outputs messages to the console in real-time.
Dual Storage System
One of the key features is the dual storage system:
- Filtered Output (
$outputarray): Contains only messages that pass the verbosity filter - Complete Dump (
$dumparray): Contains ALL messages regardless of verbosity
File Output
Save output to files with optional verbosity filtering:
File contents example:
filtered.log:
complete.log:
Advanced Usage
Dual Output Access
Custom Tags
Add custom tagged messages that don't fit standard categories:
Understanding Message Formatting
All tags are padded to 8 characters for consistent alignment:
Examples
See the examples directory for detailed examples:
example.php- Complete usage demonstration with all verbosity levels
Testing
Run the test suite:
License
This library is licensed under the MIT License. See the LICENSE file for details.
Changelog
Version 2.0.0
- Added PHP 8.1+ backed enum for type-safe verbosity levels
- Added
Verbosity::includes()method for hierarchy checking - Added
Verbosity::description()method for human-readable descriptions - Improved dual storage system documentation
- Enhanced test coverage
Version 1.0.0
- Initial release
- Basic output handling with verbosity levels
- CLI detection and console output
- File export functionality
- Tagged messages with alignment