greencape/repl
最新稳定版本:1.0.0
Composer 安装命令:
composer require greencape/repl
包简介
A generic Read-Eval-Print Loop for PHP
README 文档
README
GreenCape REPL is a simple Read-Eval-Print Loop (REPL) written in PHP. It can be combined with arbitrary evaluators for the Eval step.
Installation
composer require greencape/repl
Usage
Create an Evaluator implementing the GreenCape\REPL\EvaluatorInterface and pass it to the REPL:
use GreenCape\REPL\EvaluatorInterface; use GreenCape\REPL\ReadEvalPrintLoop; class MyEvaluator implements EvaluatorInterface { public function init(): void {} public function exit(): void {} public function eval(string $input): string { // Handle the input and return the result return $result; } } $evaluator = new MyEvaluator(); $repl = new ReadEvalPrintLoop($evaluator); $repl->run();
With init() and exit() you can implement a setup and teardown for the REPL.
The loop will read your input after a '> ' prompt' and send it to the eval() method of the Evaluator.
The result will be printed to the console.
You can enter multi line input by ending each line with a backslash.
Continuation lines are indicated by a '>> ' prompt.
To terminate the loop, enter exit.
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-20