linkorb/lua

Lua PHP: Library for extending your application with lua scripts

v1.1.0 2020-07-29 12:27 UTC

This package is auto-updated.

Last update: 2024-04-29 04:21:23 UTC


README

This library enables you to add Lua scripting support to your PHP applications.

LuaSandbox

The LuaSandbox class allows you to easily run user-supplied Lua scripts in an empty sandbox environment. This means that dangerous functions (i.e. for file and network IO) are unavailable by default. To make the sandbox useful, you register your own PHP-implemented functions that you allow the chunks to execute.

Use-cases

  • Support user-supplied scripts to respond to events in your application
  • Advanced expressions, filters, segments
  • Customizable routing
  • ... and many more :)

Usage

Check the example/ directory for a well-documented example.

About Lua

Requirements

This library requires that the PHP Lua extension is installed.

A quick install guide for Ubuntu:

# Install lua library
apt-get install -y --no-install-recommends lua5.3 liblua5.3-dev
# pecl expects liblua and includes in specific locations, so move them around a bit:
cp /usr/lib/x86_64-linux-gnu/liblua5.3.a /usr/lib/liblua.a
cp /usr/lib/x86_64-linux-gnu/liblua5.3.so /usr/lib/liblua.so
ln -s /usr/include/lua5.3 /usr/include/lua
# Install the lua extension through pecl
pecl install lua
# Activate the lua extension in your PHP config
php --ini # find out where your PHP config files are located
echo "extension=lua.so" > /path/to/my/php/conf.d/lua.ini

License

MIT. Please refer to the license file for details.

Brought to you by the LinkORB Engineering team

687474703a2f2f7777772e6c696e6b6f72622e636f6d2f642f6d6574612f74696572312f696d616765732f6c696e6b6f7262656e67696e656572696e672d6c6f676f2e706e67
Check out our other projects at linkorb.com/engineering.

Btw, we're hiring!