consolidation/output-formatters
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
dflydev/dot-access-data | v3.0.2 | 10.25 kB | MIT | prod | |
symfony/console | v7.0.7 | - | MIT | prod | |
symfony/finder | v7.0.7 | - | MIT | prod |
The "consolidation/output-formatters" is a PHP library that is primarily used to apply transformations to structured data to write output in different formats. It mainly makes it possible for command-line tool commands to get implemented in a way that is entirely independent from the Symfony Console output interfaces. The main component, known as a formatter, takes the structured data returned by a command and formats it before printing the result.
To use the "consolidation/output-formatters", you need to include it in your project. You can do this by adding the "consolidation/output-formatters" to the list of required packages in your composer.json file and running composer install. Here's the required code:
"require": {
"consolidation/output-formatters": "^4"
}
You can then declare and use the formatters in your PHP code. A simple example of a formatter would be a YAML formatter that writes the structured data to the output:
class YamlFormatter implements FormatterInterface
{
public function write(OutputInterface $output, $data, FormatterOptions $options)
{
$dumper = new Dumper();
$output->writeln($dumper->dump($data));
}
}
The comprehensive documentation for "consolidation/output-formatters" can be found directly within the GitHub repository at this url: https://github.com/consolidation/output-formatters. It covers a wide range of topics including the motivation behind the library, how to use several formatters, configuring formats for a command, rendering table cells and the API usage among other topics. The documentation is quite detailed, with numerous examples given to aid in understanding.