Overview
Run a simple command throughSandbox::host().
This is the quickest way to verify sandbox execution in your environment.
Sandbox::host().
This is the quickest way to verify sandbox execution in your environment.
<?php
require 'examples/boot.php';
use Cognesy\Sandbox\Config\ExecutionPolicy;
use Cognesy\Sandbox\Sandbox;
$policy = ExecutionPolicy::in(__DIR__)
->withTimeout(3);
$result = Sandbox::host($policy)->execute(['ls', '-Al']);
echo "Exit: {$result->exitCode()}\n";
echo "--- stdout ---\n";
echo $result->stdout() . "\n";
if ($result->stderr() !== '') {
echo "--- stderr ---\n";
echo $result->stderr() . "\n";
}
?>