Download the PHP package zero-config/cli without Composer
On this page you can find all versions of the php package zero-config/cli. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zero-config/cli
More information about zero-config/cli
Files in zero-config/cli
Package cli
Short Description CLI tooling with zero configuration required.
License MIT
Informations about the package cli
Introduction
ZeroConfig CLI is a set of CLI tools, written in PHP, that require zero configuration in order to function.
This package aims to provide a set of convenience methods to create CLI tooling without having to set up a framework or having in-depth knowledge of the inner workings of PHP CLI.
By design, it solves how to deal with large data streams. It is based on data going in, data being manipulated and then data going out. Whether the source is piped data, a local file or HTTP resource, it will be streamed line by line.
Transformation of data also occurs line by line, going in and coming out. The
same goes for output, whether it's written to a file or STDOUT
.
If an application is assembled using components from this library, your application will hold only one line of resource data in memory, at any given moment. This WILL reduce memory consumption and is a sure fire way to keep performance high in most CLI solutions.
Installation
To install the code base on which the tools are built, as a library:
Alternatively, a built executable can be downloaded as zc.phar.
Correct execution rights and put it somewhere in your path:
I/O
The I/O is easily handled by the output components of the package.
Input
Input sources are implemented as generators and can thus be used to stream data line by line.
Resource | Description |
---|---|
File | Read files from the local filesystem. |
Gzip | Read Gzip archives, like backups of databases or logs. |
STDIN | Read piped data streams. |
HTTP | Stream web resources. |
Callback | Stream data using a callback. |
Output
Output writers expect iterable data and are able to write data line by line; ideal for handling streaming data.
Writer | Description |
---|---|
File | Write to a file on the local filesystem. |
STDOUT / STDERR | Write to the console. |
Callback | Write to a callable handle. |
CSV | Write to CSV files. |
Transformers
Transformers can be used to reduce, modify or enrich the data between output.
The following is an example of the match filter. It makes use of PCRE patterns.
The above example will output:
The following are available transformers.
Group | Transformer | Description |
---|---|---|
Sequence | SkipFilter | Skip a set number of records. |
Sequence | LimitFilter | Limit the number of records to a set amount. |
String | ContainsFilter | Match input that contains a substring. |
String | LineEnding | End strings with newlines or configurable sequences. |
PCRE | MatchFilter | Input must match a given PCRE pattern. |
PCRE | ReplaceFilter | Replace input using a PCRE pattern. |
CSV | CsvParser | Parse CSV strings into (associative) arrays. |
Callback | CallbackTransformer | Create a custom transformer using a callback. |
Chaining transformers
While transformers can be chained by wrapping one transformer into the other, a convenience transformer chain is available to easily chain transformers.
Guides
- Assembling a CLI tool
- Downloading large files
- Chaining transformers
- Handling database operations
- Mapping hosts and IP addresses
General documentation
- How to use
zc.phar
- Predefined constants
All versions of cli with dependencies
ext-spl Version ^7.1