The LuaSandbox class

(PECL luasandbox >= 1.0.0)

Introduction

The LuaSandbox class creates a Lua environment and allows for execution of Lua code.

Class synopsis

class LuaSandbox {
/* Constants */
const int SAMPLES = 0;
const int SECONDS = 1;
const int PERCENT = 2;
/* Methods */
public function callFunction(string $name, mixed ...$args): array|bool
public function disableProfiler(): void
public function enableProfiler(float $period = 0.02): bool
public function getCPUUsage(): float
public function getMemoryUsage(): int
public function getPeakMemoryUsage(): int
public function getProfilerFunctionReport(int $units = LuaSandbox::SECONDS): array
public static function getVersionInfo(): array
public function loadBinary(string $code, string $chunkName = ''): LuaSandboxFunction
public function loadString(string $code, string $chunkName = ''): LuaSandboxFunction
public function pauseUsageTimer(): bool
public function registerLibrary(string $libname, array $functions): void
public function setCPULimit(float|bool $limit): void
public function setMemoryLimit(int $limit): void
public function unpauseUsageTimer(): void
public function wrapPhpFunction(callable $function): LuaSandboxFunction
}

Predefined Constants

LuaSandbox::SAMPLES
Used with LuaSandbox::getProfilerFunctionReport() to return timings in samples.
LuaSandbox::SECONDS
Used with LuaSandbox::getProfilerFunctionReport() to return timings in seconds.
LuaSandbox::PERCENT
Used with LuaSandbox::getProfilerFunctionReport() to return timings in percentages of the total.

Table of Contents

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top