# 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

LuaSandbox {
/* Constants */
const integer SAMPLES = 0 ;
const integer SECONDS = 1 ;
const integer PERCENT = 2 ;
/* Methods */
public callFunction ( string `$name` [, mixed `$...` ] ) : array|bool
public disableProfiler ( void ) : void
public enableProfiler ([ float `$period` = 0.02 ] ) : bool
public getCPUUsage ( void ) : float
public getMemoryUsage ( void ) : int
public getPeakMemoryUsage ( void ) : int
public getProfilerFunctionReport ([ int `$units` = LuaSandbox::SECONDS ] ) : array
public static getVersionInfo ( void ) : array
public loadBinary ( string `$code` [, string `$chunkName` = '' ] ) : LuaSandboxFunction
public loadString ( string `$code` [, string `$chunkName` = '' ] ) : LuaSandboxFunction
public pauseUsageTimer ( void ) : bool
public registerLibrary ( string `$libname` , array `$functions` ) : void
public setCPULimit ( float|bool `$limit` ) : void
public setMemoryLimit ( int `$limit` ) : void
public unpauseUsageTimer ( void ) : void
public 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

- LuaSandbox::callFunction — Call a function in a Lua global variable
- LuaSandbox::disableProfiler — Disable the profiler
- LuaSandbox::enableProfiler — Enable the profiler.
- LuaSandbox::getCPUUsage — Fetch the current CPU time usage of the Lua environment
- LuaSandbox::getMemoryUsage — Fetch the current memory usage of the Lua environment
- LuaSandbox::getPeakMemoryUsage — Fetch the peak memory usage of the Lua environment
- LuaSandbox::getProfilerFunctionReport — Fetch profiler data
- LuaSandbox::getVersionInfo — Return the versions of LuaSandbox and Lua
- LuaSandbox::loadBinary — Load a precompiled binary chunk into the Lua environment
- LuaSandbox::loadString — Load Lua code into the Lua environment
- LuaSandbox::pauseUsageTimer — Pause the CPU usage timer
- LuaSandbox::registerLibrary — Register a set of PHP functions as a Lua library
- LuaSandbox::setCPULimit — Set the CPU time limit for the Lua environment
- LuaSandbox::setMemoryLimit — Set the memory limit for the Lua environment
- LuaSandbox::unpauseUsageTimer — Unpause the timer paused by LuaSandbox::pauseUsageTimer
- LuaSandbox::wrapPhpFunction — Wrap a PHP callable in a LuaSandboxFunction