1. Go to this page and download the library: Download karboosx/procer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
karboosx / procer example snippets
use Karboosx\Procer;
$procer = new Karboosx\Procer();
$result = $procer->run('let a be 1.');
echo $result->get('a'); // 1
use Karboosx\Procer;
$procer = new Karboosx\Procer([
new CustomFunctionProvider()
]);
$result = $procer->run('let x be custom_function("hello world!").');
echo $result->get('x'); // "custom function result with argument: hello world!"
class CustomFunctionProvider implements \Karboosx\Procer\FunctionProviderInterface
{
public function custom_function(Context $context, array $arguments): string
{
return "custom function result with argument: {$arguments[0]}";
}
public function supports(string $functionName): bool
{
return in_array($functionName, ['custom_function']);
}
}
use Karboosx\Procer;
$procer = new Procer();
$result = $procer->runExpression('1 + 2 * 3');
echo $result; // 7
use Karboosx\Procer;
$procer = new Procer();
$result = $procer->run(<<<CODE
let a be 1.
wait for signal test_signal.
let a be 2.
CODE);
echo $result->get('a'); // 1
$result = $procer->resume($context, [], ['test_signal']);
echo $result->get('a'); // 2
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.