petrknap/external-filter
最新稳定版本:v1.3.1
Composer 安装命令:
composer require petrknap/external-filter
包简介
Library for easier work with external filters
README 文档
README
Encapsulation of a command along with its options which provides a filter method. Its primary role is to facilitate filtering operations within a pipeline, allowing for easy chaining and execution of executable filters.
use PetrKnap\ExternalFilter\Filter; # echo "H4sIAAAAAAAAA0tJLEkEAGPz860EAAAA" | base64 --decode | gzip --decompress echo Filter::new('base64', ['--decode']) ->pipe(Filter::new('gzip', ['--decompress'])) ->filter('H4sIAAAAAAAAA0tJLEkEAGPz860EAAAA');
If you want to process external data, redirect output or get errors, you can use input, output or error streams.
use PetrKnap\ExternalFilter\Filter; $errorStream = fopen('php://memory', 'w+'); Filter::new('php')->filter( '<?php fputs(fopen("php://stderr", "w"), "error");', error: $errorStream, ); rewind($errorStream); echo stream_get_contents($errorStream); fclose($errorStream);
If you want to call PHP code in the pipeline, you can via factory.
use PetrKnap\ExternalFilter\Filter; echo Filter::new(phpSnippet: 'fputs(STDOUT, fgets(STDIN));') ->filter(b'data');
Run composer require petrknap/external-filter to install it.
You can support this project via donation.
The project is licensed under the terms of the LGPL-3.0-or-later.
统计信息
- 总下载量: 69
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-or-later
- 更新时间: 2024-11-05