PHPackages                             redgnar/whisky - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. redgnar/whisky

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

redgnar/whisky
==============

Internal PHP programming language

1.0.6(2y ago)06.8k—5%MITPHPPHP &gt;=8.1

Since Dec 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/redgnar/whisky)[ Packagist](https://packagist.org/packages/redgnar/whisky)[ RSS](/packages/redgnar-whisky/feed)WikiDiscussions 1.0 Synced 1mo ago

READMEChangelog (7)Dependencies (7)Versions (18)Used By (0)

redgnar/whisky
==============

[](#redgnarwhisky)

[![Latest](https://camo.githubusercontent.com/6abe7f86380965a26984ffc73c6175543ac0c31822edb05c6639b5028af4861c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726564676e61722f776869736b792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/redgnar/whisky)[![Quality](https://github.com/redgnar/whisky/actions/workflows/quality.yml/badge.svg?branch=1.0)](https://github.com/redgnar/whisky/actions/workflows/quality.yml)[![Downloads](https://camo.githubusercontent.com/9e1ddd1649307bede4030e1b96053412bbd688fe4292c1082e0ff42de0cea681/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726564676e61722f776869736b792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/redgnar/whisky)

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
------------

[](#installation)

Use composer to install the whisky library.

`composer require redgnar/whisky`

Usage
-----

[](#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(
