Parsing Lua Scripts With PHP

Lua is a lightweight scripting language designed to be embedded in larger programs in order to allow for user customization. The most popular application to include a Lua interpreter is probably World of Warcraft. The entire user interface is customizable through Lua scripting, and a sizable community of plugin developers has grown around it.

It’s possible to include a Lua interpreter in a program built with pretty much any imaginable language…including PHP. There is a convenient PHP class, called phplua, that will allow you to do this.

phplua is a PHP extension that enables you to embed the LUA interpreter in a PHP application. Huh? A script language embedded in a script language? This is probably what you are asking yourself now. But imagine you have an application and want to allow users to customize it using some API. PHP will be sufficient if you are the webmaster and want to extend a foreign application by a separate module. But you certainly do NOT want to give an ordinary web user of this application the ability to inject their own PHP code. PHP is simply not designed to do this. At least not in a secure way.

If you have a complex web application that could do with a little bit of user customization, it’s definitely possible to bake in a Lua API. The question is: if you did that, would it make Lua a meta-scripting language?