承接 redgnar/whisky 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

redgnar/whisky

最新稳定版本:1.0.6

Composer 安装命令:

composer require redgnar/whisky

包简介

Internal PHP programming language

关键字:

README 文档

README

Latest Quality Downloads

The Whisky The library is designed for the safe execution of PHP scripts, with the ability to set input variables and read output variables. The library allows for defining custom functions as well as security rules.

Installation

Use composer to install the whisky library.

composer require redgnar/whisky

Usage

After installation, you can include the whisky library in your PHP scripts using composer auto-load.

require_once 'vendor/autoload.php';

Now, you can use the functionalities provided by the whisky library.

use PhpParser\ParserFactory;
...

$functionRepository = new FunctionRepository();
$builder = new BasicBuilder(
    new PhpParser((new ParserFactory())->create(ParserFactory::ONLY_PHP7)),
    new VariableHandler(),
    new FunctionHandler($functionRepository)
);
$builder->addExtension(new BasicSecurity());
$executor = new BasicExecutor($functionRepository);
$variables = new BasicScope(['collection' => ['a', 'b']]);
$functionRepository->addFunction('testIt', function (string $text) {return $text; });
$script = $builder->build(
            <<<'EOD'
    $result = [];
    foreach ($collection as $item) {
        if ("b" === $item) {
            continue;
        }
        $result[] = testIt($item."aaa4bbb");
    }
EOD
);
$executor->execute($script, $variables);
var_dump($variables->get('result'));

License

This library is released under an open-source license. For more information, please see the LICENSE file in the repository.

Support

For any questions or issues, you may [open an issue](Link to issue page) on our GitHub repository.

Acknowledgements

Thank you to all the contributors who have helped in developing this library.

统计信息

  • 总下载量: 6.03k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-23